Skip to content
Saiko

crypt.decrypt

Decrypts base64 text made by crypt.encrypt and returns the original string.

Signature

luau
crypt.decrypt(data: string, key: string, iv: string, mode: string): string

Parameters

datastring

The encrypted text, base64 encoded, as crypt.encrypt returned it.

keystring

The key used to encrypt, base64 encoded.

ivstring

The initialization vector used to encrypt, base64 encoded.

modestring

The cipher mode used to encrypt, for example "CBC".

Returns

string

Example

luau
local key = base64encode("GMVIsgHnxm0YDYwUGkBhtRWSrSsfRMjY")
local iv = base64encode("1234567890abcdef")

print(crypt.decrypt("jxF03fu7V3WKm7b2oRMo9HYz+KVDymqKU29qmsiTP4E=", key, iv, "CBC")) --> 1234567890abcdef