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