crypt

package
v22.11.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(ciphertext []byte, key *Key) ([]byte, error)

Decrypt decrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.

func Encrypt

func Encrypt(plaintext []byte, key *Key) ([]byte, error)

Encrypt encrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. output takes the form nonce|ciphertext|tag where '|' indicates concatenation.

func GenerateRSAKeyPair

func GenerateRSAKeyPair(name string) (privKey string, pubKey string, ferr fail.Error)

GenerateRSAKeyPair creates a key pair

Types

type Key

type Key [32]byte

Key ...

func NewEncryptionKey

func NewEncryptionKey(text []byte) (*Key, error)

NewEncryptionKey generates a random 256-bit key for Encrypt() and Decrypt(). If text is nil or empty, creates a random key. It panics if the source of randomness fails. If text is not nil and not empty, and the length of text is lower than 32, the key is completed with spaces. If text is not nil and not empty, and the length of text us greater than 32, the 32 first bytes are used as key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL