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.

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

Parameters

Function parameters
ParameterTypeDescription
cipherstringCipher name: aes-cbc, aes-cfb, aes-ctr, aes-ofb, aes-gcm, aes-eax, bf-cbc, bf-cfb, or bf-ofb.
datastringBase64 ciphertext returned by the matching custom encrypt call.
keystringRaw key bytes: AES needs 16, 24, or 32 bytes; Blowfish accepts 4 through 56 bytes.
ivstringRaw IV or nonce bytes. AES CBC/CFB/CTR/OFB need 16, Blowfish needs 8, and GCM needs a nonempty nonce.

Returns

string

Plaintext 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

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")
Kawaii documentation