Sample code for 30+ languages & platforms
Xbase++ 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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oPubkey
LOCAL oRsa
LOCAL cEncryptedStr

nSuccess := 0

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

oPubkey := CreateObject("Chilkat.PublicKey")

nSuccess := oPubkey:LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
IF (nSuccess == 0)
    ? oPubkey:LastErrorText
    oPubkey:destroy()
    RETURN
ENDIF

oRsa := CreateObject("Chilkat.Rsa")

nSuccess := oRsa:UsePublicKey(oPubkey)
IF (nSuccess == 0)
    ? oRsa:LastErrorText
    oPubkey:destroy()
    oRsa:destroy()
    RETURN
ENDIF

oRsa:EncodingMode := "base64"

cEncryptedStr := oRsa:EncryptStringENC("12345678", 0)

? cEncryptedStr

oPubkey:destroy()
oRsa:destroy()