Visual FoxPro
Visual FoxPro
Load PEM Public/Private Key into RSA Object
See more RSA Examples
Demonstrates how to load a PEM key into the Chilkat RSA object.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loRsa
LOCAL lcPublicKeyPem
LOCAL loPubkey
LOCAL lcPrivateKeyPem
LOCAL loPrivkey
lnSuccess = 0
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loRsa = CreateObject('Chilkat.Rsa')
* First demonstrate importing a PEM public key:
lcPublicKeyPem = "PEM public-key data goes here"
loPubkey = CreateObject('Chilkat.PublicKey')
lnSuccess = loPubkey.LoadFromString(lcPublicKeyPem)
IF (lnSuccess = 0) THEN
? loPubkey.LastErrorText
RELEASE loRsa
RELEASE loPubkey
CANCEL
ENDIF
lnSuccess = loRsa.UsePublicKey(loPubkey)
IF (lnSuccess = 0) THEN
? loRsa.LastErrorText
RELEASE loRsa
RELEASE loPubkey
CANCEL
ENDIF
* Demonstrate importing a PEM private key:
lcPrivateKeyPem = "PEM private-key data goes here"
loPrivkey = CreateObject('Chilkat.PrivateKey')
* If the private key PEM is protected with a password, then
* call LoadEncryptedPem. Otherwise call LoadPem.
lnSuccess = loPrivkey.LoadPem(lcPrivateKeyPem)
IF (lnSuccess = 0) THEN
? loPrivkey.LastErrorText
RELEASE loRsa
RELEASE loPubkey
RELEASE loPrivkey
CANCEL
ENDIF
lnSuccess = loRsa.UsePrivateKey(loPrivkey)
IF (lnSuccess = 0) THEN
? loRsa.LastErrorText
RELEASE loRsa
RELEASE loPubkey
RELEASE loPrivkey
CANCEL
ENDIF
? "OK!"
RELEASE loRsa
RELEASE loPubkey
RELEASE loPrivkey