(Xojo Plugin) RSA Import Public Key from Certificate PEM
Uses a certificate's public key for RSA encryption. The public key from the certificate .pem file is used.
Dim cert As New Chilkat.Cert
Dim success As Boolean
success = cert.LoadFromFile("qa_data/pem/mf_public_rsa.pem")
If (success = False) Then
System.DebugLog(cert.LastErrorText)
Return
End If
Dim pubKey As Chilkat.PublicKey
pubKey = cert.ExportPublicKey()
If (cert.LastMethodSuccess <> True) Then
System.DebugLog(cert.LastErrorText)
Return
End If
Dim rsa As New Chilkat.Rsa
success = rsa.ImportPublicKeyObj(pubKey)
If (success = False) Then
System.DebugLog(rsa.LastErrorText)
Return
End If
rsa.EncodingMode = "base64"
Dim encryptedStr As String
encryptedStr = rsa.EncryptStringENC("hello",False)
System.DebugLog("encrypted string = " + encryptedStr)
|