Lua
Lua
Example: Crypt2.DecryptStringENC method
Demonstrates how to call the DecryptStringENC method.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local crypt = chilkat.Crypt2.new()
crypt.crypt_algorithm = "aes"
crypt.cipher_mode = "cbc"
crypt.key_length = 128
crypt:set_encoded_key("000102030405060708090A0B0C0D0E0F", "hex")
crypt:set_encoded_iv("000102030405060708090A0B0C0D0E0F", "hex")
crypt.encoding_mode = "base64"
-- Return the base64 encoded encrypted bytes
local encodedEncrypted = crypt:encrypt_string_enc("Hello World!")
print("Encrypted: " .. encodedEncrypted)
-- Output:
-- Encrypted: qiq+IFhcjTkEIkZyf31V/g==
-- Decrypt
local originalText = crypt:decrypt_string_enc(encodedEncrypted)
print("Decrypted: " .. originalText)
-- Output:
-- Decrypted: Hello World!