(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.
LOCAL loPubkey
LOCAL lnSuccess
LOCAL loRsa
LOCAL lcEncryptedStr
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.PublicKey')
loPubkey = CreateObject('Chilkat.PublicKey')
lnSuccess = loPubkey.LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
IF (lnSuccess <> 1) THEN
? loPubkey.LastErrorText
RELEASE loPubkey
CANCEL
ENDIF
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Rsa')
loRsa = CreateObject('Chilkat.Rsa')
lnSuccess = loRsa.ImportPublicKeyObj(loPubkey)
IF (lnSuccess <> 1) THEN
? loRsa.LastErrorText
RELEASE loPubkey
RELEASE loRsa
CANCEL
ENDIF
loRsa.EncodingMode = "base64"
lcEncryptedStr = loRsa.EncryptStringENC("12345678",0)
? lcEncryptedStr
RELEASE loPubkey
RELEASE loRsa
|