Sample code for 30+ languages & platforms
Lua

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local crypt = chilkat.Crypt2.new()

local bdEncrypted = chilkat.BinData.new()
local sbPlainText = chilkat.StringBuilder.new()

sbPlainText:append("Text to be encrypted")

-- ...
-- Set the secret key ...
-- Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
-- Set the IV if needed ...
-- ...

crypt.charset = "utf-8"

local success = crypt:encrypt_sb(sbPlainText, bdEncrypted)
if not success then
    print(crypt.last_error_text)
    return
end