Sample code for 30+ languages & platforms
Xojo Plugin

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 Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

Dim cert As New Chilkat.Cert

success = cert.LoadFromFile("qa_data/pem/mf_public_rsa.pem")
If (success = False) Then
    System.DebugLog(cert.LastErrorText)
    Return
End If

Dim pubKey As New Chilkat.PublicKey
success = cert.GetPublicKey(pubKey)

Dim rsa As New Chilkat.Rsa
success = rsa.UsePublicKey(pubKey)

rsa.EncodingMode = "base64"
Dim encryptedStr As String
encryptedStr = rsa.EncryptStringENC("hello",False)
System.DebugLog("encrypted string = " + encryptedStr)