Sample code for 30+ languages & platforms
VB.NET

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 VB.NET Downloads

VB.NET
Dim success As Boolean = False

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

Dim pubkey As New Chilkat.PublicKey

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


Dim rsa As New Chilkat.Rsa

success = rsa.UsePublicKey(pubkey)
If (success = False) Then
    Debug.WriteLine(rsa.LastErrorText)
    Exit Sub
End If


rsa.EncodingMode = "base64"

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

Debug.WriteLine(encryptedStr)