Sample code for 30+ languages & platforms
B4X Requires Chilkat v11.0.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 B4X Downloads

B4X
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 ChilkatPublicKey
pubkey.Initialize

success = pubkey.LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
If success = False Then
    Log(pubkey.LastErrorText)
    Return
End If


Dim rsa As ChilkatRsa
rsa.Initialize

success = rsa.UsePublicKey(pubkey)
If success = False Then
    Log(rsa.LastErrorText)
    Return
End If


rsa.EncodingMode = "base64"

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

Log(encryptedStr)