Documentation
¶
Overview ¶
Package transcrypt provides functionality to encrypt arbitrary data into a hex encoded string for safe on-disk storage, and decrypt said string.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateHexKey ¶
CreateHexKey generates a random key which can be used for encryption. It generates a RSA Private Key with the supplied bitSize, and converts it to a hex-encoded PEM Block.
func CreateSalt ¶
CreateSalt creates a random 12-byte salt for use with the encrypt/decrypt functionality.
func Decrypt ¶
Decrypt decrypts a supplied hex-encoded data string using the supplied secret key. It will return an error if either the key or the data is empty. If the hex-encoded string data cannot be converted into proper encrypted data, decryption will also fail with an error.
func Encrypt ¶
Encrypt encrypts the supplied data using the supplied secret key and cipher suite. It will return an error if either the key is empty or the data is nil. Additionally, if the necessary cryptographic configuration cannot be created using the supplied cipherSuite, it will return an error. If a salt is provided, it must be at least 12 bytes. If salt is nil, the function will automatically create one on-the-fly.
Types ¶
type CipherSuite ¶
type CipherSuite byte
CipherSuite defines which cipher suites can be used for transcryption of data. It is based on the types available in github.com/minio/sio .
const ( AES_256_GCM CipherSuite = iota CHACHA20_POLY1305 )
func GetCipherSuite ¶
func GetCipherSuite(s string) CipherSuite
GetCipherSuite converts a string into its respective CipherSuite. It returns CHACHA20_POLY1305 by default if the string cannot be converted.