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.
Luau
syn.crypt.decrypt(data: string, key: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
data | string | Base64 ciphertext envelope. |
key | string | The same raw key material supplied to syn.crypt.encrypt. |
Returns
stringThe 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
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