Documentation
¶
Index ¶
- Variables
- func Decrypt(cipherText, key []byte) (decrypted []byte, err error)
- func DecryptFromString(cipherTextStr string, key []byte) (decrypted []byte, err error)
- func Encrypt(plainText, key []byte) (encrypted []byte, err error)
- func EncryptToString(plainText, key []byte) (string, error)
- func GenerateRandomString(length int) (string, error)
- func PassphraseToKey(passphrase string) (key []byte)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCipherTooShort occurs when `Decrypt` does not // have input of enough length to decrypt using AES256 ErrCipherTooShort = errors.New("crypto: cipher plainText is too short for AES encryption") )
Functions ¶
func DecryptFromString ¶
DecryptFromString decrypts a string with a key
func EncryptToString ¶
EncryptToString encrypts content with a key using AES256 and encodes it to a hexadecimal string
func GenerateRandomString ¶
GenerateRandomString generates a random string with a given length
func PassphraseToKey ¶
PassphraseToKey converts a string to a key for encryption.
This function must be used STRICTLY ONLY for generating an encryption key out of a passphrase. Please don't use this function for hashing user-provided values. It uses SHA2 for simplicity but it's slower. User-provided data should use SHA3 because of its better performance.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.