Skip to content

crypto.decrypt

Decrypts data using a cipher algorithm, key, and optional initialization vector (IV).

Signature

luau
function decrypt(algorithm: CipherAlgorithm, data: string, key: string, iv: string?): string

Types

luau
type CipherAlgorithm = "aes-256-cbc" | "aes-256-gcm" | "aes-256-ctr"

Summary

Parameters

ParameterTypeDescription
algorithmCipherAlgorithmThe cipher algorithm used for original encryption.
datastringThe encrypted data to decrypt.
keystringThe decryption key.
ivstring?The initialization vector.

Example

lua
local crypto = require("@runtime/crypto")

local decrypted = crypto.decrypt("aes-256-cbc", encryptedData, "my-32-byte-long-key-string!!!", "16-byte-iv-string")
print(decrypted) -- Hello, World!