Encoding & cryptographyReference
crypt.decrypt
Decrypt Base64-encoded AES-256-CBC data.
Details#
Decrypt Base64-encoded AES-256-CBC data. Raw plaintext bytes. Invalid Base64, key, IV, mode or padding/decryption failure raises an error.
Signature#
crypt.decrypt(data: string, key: string, iv: string, mode: string?): stringParameters#
| Parameter | Type | Description |
|---|---|---|
data | string | Base64 ciphertext produced by encrypt. |
key | string | Base64 encoding of the same 32-byte key. |
iv | string | Base64 IV with at least 16 decoded bytes; first 16 are used. |
modeoptional | string | CBC only; default CBC, case-insensitive. |
Returns#
Raw plaintext bytes. Invalid Base64, key, IV, mode or padding/decryption failure raises an error.
Examples#
Local example
local key = crypt.generatekey()
local data, iv = crypt.encrypt("Saved locally", key)
print(crypt.decrypt(data, key, iv)) -- Saved locally