crypt.encrypt
Encrypts a string with AES and returns the result as base64.
Signature
crypt.encrypt(data: string, key: string, iv: string, mode: string): stringParameters
datastringThe plain text to encrypt.
keystringThe key, base64 encoded. A key made by crypt.generatekey has the right size.
ivstringThe initialization vector, base64 encoded, 16 bytes before encoding.
modestringThe cipher mode. "CBC" is the one the Myriad checks use.
Returns
string
Note
Example
local key = crypt.generatekey()
local iv = crypt.generatebytes(16)
local encrypted = crypt.encrypt("hello world", key, iv, "CBC")
print(encrypted) --> base64 text
print(crypt.decrypt(encrypted, key, iv, "CBC")) --> hello world