Xbasic
aes_gcm_encrypt Function
Syntax
c aes_gcm_encrypt(c plaintext, c key[, c nonce])
Arguments
- plaintext
Text to encrypt.
- key
Symmetric key used for encryption.
- nonce
Optional nonce used for AES-GCM. If omitted, a random nonce is used. You must remember the nonce to decrypt the ciphertext later.
Returns
- result
A colon-separated base64 string in the form `ciphertext:tag`. The nonce is not embedded and must be stored separately if a random nonce was used.
Description
Encrypt plaintext using AES-GCM with the given key and optional nonce.
Examples
Encrypt with random nonce (must be remembered separately)
txt = aes_gcm_encrypt("Keep it a secret","Shhh!")
? txt
= "TLlmtlbYLebhs46rS98Aqg==:fq3D+e6FLRBQ0NtVPTOl0Q=="You must remember the nonce used for encryption (even when randomly generated) in order to decrypt successfully later.