Sample code for 30+ languages & platforms
Visual Basic 6.0

Use Base64 RSA Key to Encrypt

See more RSA Examples

Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

Dim pubkey As New PublicKey

success = pubkey.LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
If (success = 0) Then
    Debug.Print pubkey.LastErrorText
    Exit Sub
End If

Dim rsa As New ChilkatRsa

success = rsa.UsePublicKey(pubkey)
If (success = 0) Then
    Debug.Print rsa.LastErrorText
    Exit Sub
End If

rsa.EncodingMode = "base64"

Dim encryptedStr As String
encryptedStr = rsa.EncryptStringENC("12345678",0)

Debug.Print encryptedStr