Lua
Lua
Duplicate openssl smime -decrypt -in some_file.dat.enc -binary -inform DER -inkey private.key -out some_file.dat
See more OpenSSL Examples
Demonstrates how to decrypt binary DER that was encrypted using the following openssl command:openssl smime -encrypt -binary -aes-256-cbc -in some_file.dat -out some_file.dat.enc -outform DER cert.crt
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.
-- Duplicates the following openssl command:
-- openssl smime -decrypt -in hello.txt.enc -binary -inform DER -inkey private.key -out hello.txt
local cert = chilkat.Cert.new()
local success = cert:load_from_file("qa_data/openssl/EE.cer")
if not success then
print(cert.last_error_text)
return
end
local bd = chilkat.BinData.new()
success = bd:load_file("qa_data/openssl/EE.key")
-- Assuming success..
local privKey = chilkat.PrivateKey.new()
success = privKey:load_any_format(bd, "")
if not success then
print(privKey.last_error_text)
return
end
local crypt = chilkat.Crypt2.new()
success = crypt:set_decrypt_cert2(cert, privKey)
if not success then
print(crypt.last_error_text)
return
end
crypt.crypt_algorithm = "PKI"
success = crypt:ck_decrypt_file("qa_data/openssl/hello.txt.enc", "qa_output/hello.txt")
if not success then
print(crypt.last_error_text)
return
end
print("Success.")