syn.crypt.decrypt Synchronous

  • syn.crypto.decrypt

Decrypt an envelope produced by syn.crypt.encrypt. Use it to restore data saved by the matching compatibility encryption function. The same input key material must be available at decryption time.

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

Parameters

Function parameters
ParameterTypeDescription
datastringBase64 ciphertext envelope.
keystringThe same raw key material supplied to syn.crypt.encrypt.

Returns

string

The original plaintext bytes. Invalid envelopes or authentication failures raise an error.

Availability

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

Example

Example
Luau
-- Enable the Synapse environment setting before running this example.
local key = syn.crypt.random(32)
local ciphertext = syn.crypt.encrypt("example note", key)
print(syn.crypt.decrypt(ciphertext, key)) -- example note
Kawaii documentation