syn.crypt.decrypt Synchronous

  • syn.crypto.decrypt

Open an envelope produced by syn.crypt.encrypt. It checks the envelope and authentication tag before returning the original bytes.

Syntax
Luau
syn.crypt.decrypt(data: string, key: string) -> string

Parameters

Function parameters
ParameterTypeDescription
datastringBase64 ciphertext envelope from syn.crypt.encrypt.
keystringThe same raw key material used at encryption time.

Returns

string

The original plaintext byte string. Unsupported envelopes, bad keys, and changed ciphertext raise errors.

Usage notes

Use pcall when reading an external or old saved value. A crypt.encrypt ciphertext belongs to a different format.

Availability

This function requires the Synapse environment setting, which is off by default.

Example

Example
Luau
local key = "example passphrase"
local sealed = syn.crypt.encrypt("saved note", key)
local ok, text = pcall(syn.crypt.decrypt, sealed, key)
if ok then print(text) end
Kawaii documentation