(Visual FoxPro) Use Base64 RSA Key to Encrypt
Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64. Note: This example requires Chilkat v11.0.0 or greater.
LOCAL lnSuccess
LOCAL loPubkey
LOCAL loRsa
LOCAL lcEncryptedStr
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loPubkey = CreateObject('Chilkat.PublicKey')
lnSuccess = loPubkey.LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
IF (lnSuccess = 0) THEN
? loPubkey.LastErrorText
RELEASE loPubkey
CANCEL
ENDIF
loRsa = CreateObject('Chilkat.Rsa')
lnSuccess = loRsa.UsePublicKey(loPubkey)
IF (lnSuccess = 0) THEN
? loRsa.LastErrorText
RELEASE loPubkey
RELEASE loRsa
CANCEL
ENDIF
loRsa.EncodingMode = "base64"
lcEncryptedStr = loRsa.EncryptStringENC("12345678",0)
? lcEncryptedStr
RELEASE loPubkey
RELEASE loRsa
|