Skip to content

crypto.secretbox.open

Decrypts and verifies an authenticated message using a secret key.

Signature

luau
function open(box: string, key: string, nonce: string?): string?

Summary

Parameters

ParameterTypeDescription
boxstringThe sealed data to be opened.
keystringThe secret key used for sealing.
noncestring?The nonce used for sealing.

Example

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

local message = crypto.secretbox.open(box, key)
if message then
    print("Decrypted message:", message)
else
    print("Failed to decrypt or authenticate!")
end