CkPython
CkPython
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 CkPython Downloads
import sys
import chilkat
success = False
cert = chilkat.CkCert()
success = cert.LoadFromFile("qa_data/pem/mf_public_rsa.pem")
if (success == False):
print(cert.lastErrorText())
sys.exit()
pubKey = chilkat.CkPublicKey()
cert.GetPublicKey(pubKey)
rsa = chilkat.CkRsa()
rsa.UsePublicKey(pubKey)
rsa.put_EncodingMode("base64")
encryptedStr = rsa.encryptStringENC("hello",False)
print("encrypted string = " + encryptedStr)