Documentation
¶
Overview ¶
Package crypto provides encryption and decryption utilities using AES-GCM. AES-GCM is an authenticated encryption scheme that provides both confidentiality and integrity protection.
Index ¶
- Variables
- func AESDecrypt(key, ciphertext []byte) ([]byte, error)
- func AESDecryptString(key []byte, encoded string) (string, error)
- func AESEncrypt(key, plaintext []byte) ([]byte, error)
- func AESEncryptString(key []byte, plaintext string) (string, error)
- func GenerateAESKey(size int) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AESDecrypt ¶
AESDecrypt decrypts ciphertext that was encrypted with AESEncrypt. Expects the nonce to be prepended to the ciphertext.
func AESDecryptString ¶
AESDecryptString decrypts a base64-encoded ciphertext string.
func AESEncrypt ¶
AESEncrypt encrypts plaintext using AES-GCM with the given key. The key must be 16, 24, or 32 bytes long (AES-128, AES-192, AES-256). Returns the nonce prepended to the ciphertext.
func AESEncryptString ¶
AESEncryptString encrypts a plaintext string and returns a base64-encoded ciphertext.
func GenerateAESKey ¶
GenerateAESKey generates a random AES key of the specified byte size. Valid sizes are 16 (AES-128), 24 (AES-192), or 32 (AES-256).
Types ¶
This section is empty.