Sample code for 30+ languages & platforms
Visual FoxPro

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loCert
LOCAL loDecrypt
LOCAL loBd

lnSuccess = 0

loCert = CreateObject('Chilkat.Cert')

lnSuccess = loCert.LoadPfxFile("c:/pfx_files/my.pfx","password")
IF (lnSuccess <> 1) THEN
    ? loCert.LastErrorText
    RELEASE loCert
    CANCEL
ENDIF

loDecrypt = CreateObject('Chilkat.Crypt2')
loDecrypt.CryptAlgorithm = "pki"

lnSuccess = loDecrypt.SetDecryptCert(loCert)
IF (lnSuccess <> 1) THEN
    ? loDecrypt.LastErrorText
    RELEASE loCert
    RELEASE loDecrypt
    CANCEL
ENDIF

loBd = CreateObject('Chilkat.BinData')
lnSuccess = loBd.LoadFile("c:/someDir/pkcs7_encrypted.dat")

lnSuccess = loDecrypt.DecryptBd(loBd)
IF (lnSuccess <> 1) THEN
    ? loDecrypt.LastErrorText
    RELEASE loCert
    RELEASE loDecrypt
    RELEASE loBd
    CANCEL
ENDIF

* bd contains the decrypted content.

RELEASE loCert
RELEASE loDecrypt
RELEASE loBd