Crypto
crypto.encrypt
Shared
Encrypts a string into a cryptographically encrypted string
Syntax
local result, iv = crypto.encrypt(mode, input, key)Parameters
| Type | Name | Description |
|---|---|---|
string | mode | Encryption mode: • "AES128" - Advanced Encryption Standard 128-bit• "AES192" - Advanced Encryption Standard 192-bit• "AES256" - Advanced Encryption Standard 256-bit |
string | input | String containing data to be encrypted |
string | key | Key to be used for encryption |
Returns
| Type | Name | Description |
|---|---|---|
string / bool | result | Encrypted string on successful execution, or false on failure |
string / nil | iv | Generated initialization vector on successful execution, or nil on failure |
Examples
local input = "Hello World"
local key = "MySecretKey12345"
local output, iv = crypto.encrypt("AES256", input, key)
engine.print("Input:", input)
engine.print("Encrypted:", output, "IV:", iv)