Xbasic

aes_gcm_nonce Function

Syntax

c aes_gcm_nonce()

Returns

nonce

Randomly generated nonce string.

Description

Generate a random nonce for AES-GCM. The nonce must be remembered for decryption.

Example

Generate and use a nonce
non = aes_gcm_nonce()
? non
= "PKat/c4FH9/ehoJd"
txt = aes_gcm_encrypt("Keep it a secret","Shhh!",non)
? aes_gcm_decrypt(txt,"Shhh!",non)
= "Keep it a secret"
Store the nonce securely with the ciphertext. Using the wrong or missing nonce will cause decryption to fail.