Documentation ¶
Overview ¶
Package crypto provides a small wrapper around cryptopasta.
Index ¶
- Constants
- func Decrypt(ciphertext []byte, key *AES256Key) ([]byte, error)
- func DecryptStringFromBase64(base64Ciphertext string, key *AES256Key) (plaintext string, err error)
- func Encrypt(plaintext []byte, key *AES256Key) ([]byte, error)
- func EncryptStringToBase64(plaintext string, key *AES256Key) (base64Ciphertext string, err error)
- func Equal(k1, k2 *AES256Key) bool
- type AES256Key
Constants ¶
const AES256KeyLengthInBytes = 32
AES256KeyLengthInBytes is the length, in bytes, of a 256-bit AES key
Variables ¶
This section is empty.
Functions ¶
func DecryptStringFromBase64 ¶
DecryptStringFromBase64 decodes the provided base64 string (e.g. from a previous call to EncryptStringToBase64), decrypts the result with the provided key, and returns the resulting string.
func EncryptStringToBase64 ¶
EncryptStringToBase64 encrypts the plaintext with the provided key and returns the base64-encoded result.
Types ¶
type AES256Key ¶
type AES256Key [AES256KeyLengthInBytes]byte
AES256Key represents a 256-bit AES key
func NewAESKeyFromBase64 ¶
NewAESKeyFromBase64 loads the base64-encoded string into the current AES256Key.
func NewRandomAESKey ¶
func NewRandomAESKey() *AES256Key
NewRandomAESKey returns a new, cryptographically generated 256-bit AES key. NewRandomAESKey will panic if the source of randomness fails.