|  Developer
Updated on May 17, 2022

encrypt

Edit
fields type description
cipher table Cipher settings
data string Target data for encryption.
Edit
fields type description
encrypted_data string encrypted data
Edit
Edit
				
					local security = require("security")
local cipher = { 
    type = "aes", 
    key = "StringKeyStringK", 
    mode = "ofb"
} --string key (size 16 bytes) and empty initialization vector
local encrypted_data = security.encrypt( cipher, "data for encryption" )				
			
Edit
				
					local security = require("security")
local cipher = { 
    key = "\x17\xC6\x3C\x37\xDE\x19\xCF\x00\x6A\xC9\x15\x1A\x00\x3C\x78\x43", 
    mode = "cbc" 
} --binary key (size 16 bytes) and empty initialization vector
local encrypted_data = security.encrypt( cipher, "data for encryption" )				
			
Edit
				
					local security = require("security")
local cipher = { 
    key = "\x09\x76\x28\x34\x3f\xe9\x9e\x23\x76\x5c\x15\x13\xac\xcf\x8b\x02", 
    iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28\xdd\xb3\xba\x69\x5a\x2e\x6f\x58" 
} --binary key (size 16 bytes) and binary initialization vector
local encrypted_data = security.encrypt( cipher, "data for encryption" )				
			
Edit
				
					local security = require("security")
local cipher = { 
    key = "\x17\xC6\x3C\x37\xDE\x19\xCF\x00\x6A\xC9\x15\x1A\x00\x3C\x78\x43", 
    iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
    auto_padding = false
} --disabled auto padding
local encrypted_data = security.encrypt( cipher, "Data must be multiple of 16\x00\x00\x00\x00\x00" )