Standard library
AES-GCM
AES-256-GCM encrypt and decrypt.
Introduction
AES-256-GCM encrypt and decrypt. Import std/crypto/aes_gcm to bind the module as aes_gcm. Call free functions as aes_gcm.name(...). Struct methods use a receiver value.
/ std/crypto/aes_gcm
This page is the package reference for std/crypto/aes_gcm. Private helpers used only by co-located tests are not listed.
Functions
Free functions on aes_gcm. Each function has a short description, an example, then parameters and return shape.
encrypt
Encrypts plaintext with AES-256-GCM. Call form: aes_gcm.encrypt(key, nonce, plaintext).
/ std/crypto/aes_gcm
$ c = aes_gcm.encrypt(b"0123456789abcdef0123456789abcdef", b"0123456789ab", b"hi")
Parameters: key: 32-byte key. nonce: 12-byte nonce. plaintext: bytes to encrypt. Returns: Ciphertext bytes including auth tag.
decrypt
Decrypts AES-256-GCM ciphertext. Call form: aes_gcm.decrypt(key, nonce, ciphertext).
/ std/crypto/aes_gcm
$ p = aes_gcm.decrypt(key, nonce, ciphertext)
Parameters: key: 32-byte key. nonce: 12-byte nonce. ciphertext: bytes to decrypt. Returns: Plaintext bytes, or failure on auth error.