Lua Requires Chilkat v11.0.0+
Lua
RSA Import Public Key from Certificate PEM
See more RSA Examples
Uses a certificate's public key for RSA encryption. The public key from the certificate .pem file is used.Chilkat Lua Downloads
local chilkat = require("chilkat")
local cert = chilkat.Cert.new()
local success = cert:load_from_file("qa_data/pem/mf_public_rsa.pem")
if not success then
print(cert.last_error_text)
return
end
local pubKey = chilkat.PublicKey.new()
cert:get_public_key(pubKey)
local rsa = chilkat.Rsa.new()
rsa:use_public_key(pubKey)
rsa.encoding_mode = "base64"
local encryptedStr = rsa:encrypt_string_enc("hello", false)
print("encrypted string = " .. encryptedStr)