AcediaDocumentation

crypt.decrypt

Decrypts Base64 AES-256-CBC ciphertext.

Returns the original raw plaintext. Uses the same key/IV folding as crypt.encrypt.

crypt.decrypt(ciphertext: string, key: string, iv: string): string

Parameters

ParameterTypeDescription
ciphertextstringBase64 ciphertext from crypt.encrypt.
keystringBase64 key material.
ivstringBase64 IV returned by crypt.encrypt.

Example

local key = crypt.generatekey()
local ciphertext, iv = crypt.encrypt("example", key)
local plaintext = crypt.decrypt(ciphertext, key, iv)
print(plaintext)

Example output

example

Errors: Invalid Base64, non-block-aligned ciphertext and invalid padding can raise decryption errors.

On this page