Documentation ¶
Overview ¶
Package encrypt provides symmetric authenticated encryption using 256-bit AES-GCM with a random nonce.
Index ¶
- func AesDecrypt(ciphertext []byte, key *[]byte) (plaintext []byte, err error)
- func AesEncrypt(plaintext []byte, key *[]byte) (ciphertext []byte, err error)
- func Decrypt(privateKeyPath string, output string) (string, error)
- func Encrypt(publicKeyPath string, output string, data []byte) (encryptedKey, encryptedData string)
- func NewAesEncryptionKey() *[]byte
- func ReadRsaPrivateKey(key string) *rsa.PrivateKey
- func ReadRsaPublicKey(key string) *rsa.PublicKey
- func RsaDecrypt(payload string, key *rsa.PrivateKey) (*[]byte, error)
- func RsaEncrypt(payload *[]byte, key *rsa.PublicKey) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesDecrypt ¶
AesDecrypt 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 AesEncrypt ¶
AesEncrypt 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 NewAesEncryptionKey ¶
func NewAesEncryptionKey() *[]byte
NewAesEncryptionKey generates a random 256-bit key for Encrypt() and Decrypt(). It panics if the source of randomness fails.
func ReadRsaPrivateKey ¶
func ReadRsaPrivateKey(key string) *rsa.PrivateKey
ReadRsaPrivateKey sets the private key
func ReadRsaPublicKey ¶
ReadRsaPublicKey sets the public key
func RsaDecrypt ¶
func RsaDecrypt(payload string, key *rsa.PrivateKey) (*[]byte, error)
RsaDecrypt decrypts the data
Types ¶
This section is empty.