syn. crypt. custom. decrypt Synchronous
syn.crypto.custom.decrypt
Decrypt a Base64 value produced by syn.crypt.custom.encrypt. Match its cipher, key, and IV exactly; this function does not infer them from the ciphertext.
Luau
syn.crypt.custom.decrypt(
cipher: string,
data: string,
key: string,
iv: string
) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
cipher | string | Cipher name: aes-cbc, aes-cfb, aes-ctr, aes-ofb, aes-gcm, aes-eax, bf-cbc, bf-cfb, or bf-ofb. |
data | string | Base64 ciphertext returned by the matching custom encrypt call. |
key | string | Raw key bytes: AES needs 16, 24, or 32 bytes; Blowfish accepts 4 through 56 bytes. |
iv | string | Raw IV or nonce bytes. AES CBC/CFB/CTR/OFB need 16, Blowfish needs 8, and GCM needs a nonempty nonce. |
Returns
stringPlaintext bytes. Invalid encoding, incompatible parameters, and authentication failures raise errors.
Usage notes
This is separate from syn.crypt.decrypt, which expects Kawaii’s versioned default envelope.
Availability
This function requires the Synapse environment setting, which is off by default.
Example
Luau
local key = "0123456789abcdef0123456789abcdef" -- 32 raw bytes
local iv = "0123456789abcdef" -- 16 raw bytes
local cipher = "aes-cbc"
local ciphertext = syn.crypt.custom.encrypt(cipher, "saved note", key, iv)
assert(syn.crypt.custom.decrypt(cipher, ciphertext, key, iv) == "saved note")