Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

RSA Import Private Key

See more RSA Examples

Shows how to select/import a private key for RSA signing or decryption.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oPrivKey
LOCAL cPassword
LOCAL oRsa

nSuccess := 0

oPrivKey := CreateObject("Chilkat.PrivateKey")
cPassword := "secret"
//  In all Chilkat methods expecting a path, you pass either absolute or relative paths.
nSuccess := oPrivKey:LoadAnyFormatFile("rsaKeys/myTestRsaPrivate.pem", cPassword)
IF (nSuccess == 0)
    ? oPrivKey:LastErrorText
    oPrivKey:destroy()
    RETURN
ENDIF

oRsa := CreateObject("Chilkat.Rsa")

//  Tell the RSA object to use the private key (i.e. import the private key)
oRsa:UsePrivateKey(oPrivKey)

oPrivKey:destroy()
oRsa:destroy()