Chilkat2-Python
Chilkat2-Python
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 Chilkat2-Python Downloads
import sys
import chilkat2
success = False
cert = chilkat2.Cert()
success = cert.LoadFromFile("qa_data/pem/mf_public_rsa.pem")
if (success == False):
print(cert.LastErrorText)
sys.exit()
pubKey = chilkat2.PublicKey()
cert.GetPublicKey(pubKey)
rsa = chilkat2.Rsa()
rsa.UsePublicKey(pubKey)
rsa.EncodingMode = "base64"
encryptedStr = rsa.EncryptStringENC("hello",False)
print("encrypted string = " + encryptedStr)