Skip to content

crypto.secretbox.seal ​

Encrypts and authenticates a message using a secret key and a nonce.

Signature ​

luau
function seal(message: string, key: string, nonce: string?): string

Summary ​

Parameters ​

ParameterTypeDescription
messagestringThe data to be encrypted and authenticated.
keystringThe secret key (32 bytes).
noncestring?An optional nonce (24 bytes). If not provided, one is generated automatically.

Example ​

lua
local crypto = require("@runtime/crypto")

local key = crypto.secretbox.keygen()
local box = crypto.secretbox.seal("Hello, World!", key)

print(box)