Lua
Lua
Example: Crypt2.ClearEncryptCerts method
Demonstrates how to call the ClearEncryptCerts method.Chilkat Lua Downloads
local chilkat = require("chilkat")
local crypt = chilkat.Crypt2.new()
-- Tell the crypt object to use 3 certificates.
-- Do this by calling AddEncryptCert for each certificate.
local cert1 = chilkat.Cert.new()
-- ...
-- Load the cert from a source such as a .pfx/.p12 file, smart card, USB token, Apple keychain, Windows certificate store, etc.
-- ...
crypt:add_encrypt_cert(cert1)
local cert2 = chilkat.Cert.new()
-- ...
crypt:add_encrypt_cert(cert2)
local cert3 = chilkat.Cert.new()
-- ...
crypt:add_encrypt_cert(cert3)
-- Params for public-key encryption to create PKCS7 enveloped-data
crypt.crypt_algorithm = "pki"
crypt.pkcs7_crypt_alg = "aes"
crypt.key_length = 256
crypt.oaep_hash = "sha256"
crypt.oaep_padding = true
local bd = chilkat.BinData.new()
-- ...
local success = crypt:encrypt_bd(bd)
-- Let's say we now want to encrypt something else with different certs..
-- First clear the encryption certs.
crypt:clear_encrypt_certs()
local cert4 = chilkat.Cert.new()
-- ...
crypt:add_encrypt_cert(cert4)
local cert5 = chilkat.Cert.new()
-- ...
crypt:add_encrypt_cert(cert5)
-- ...
-- ...
-- Encrypt using cert4 and cert5.
success = crypt:encrypt_bd(bd)