Sample code for 30+ languages & platforms
Xbase++

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oCert
LOCAL oDecrypt
LOCAL oBd

nSuccess := 0

oCert := CreateObject("Chilkat.Cert")

nSuccess := oCert:LoadPfxFile("c:/pfx_files/my.pfx", "password")
IF (nSuccess != 1)
    ? oCert:LastErrorText
    oCert:destroy()
    RETURN
ENDIF

oDecrypt := CreateObject("Chilkat.Crypt2")
oDecrypt:CryptAlgorithm := "pki"

nSuccess := oDecrypt:SetDecryptCert(oCert)
IF (nSuccess != 1)
    ? oDecrypt:LastErrorText
    oCert:destroy()
    oDecrypt:destroy()
    RETURN
ENDIF

oBd := CreateObject("Chilkat.BinData")
nSuccess := oBd:LoadFile("c:/someDir/pkcs7_encrypted.dat")

nSuccess := oDecrypt:DecryptBd(oBd)
IF (nSuccess != 1)
    ? oDecrypt:LastErrorText
    oCert:destroy()
    oDecrypt:destroy()
    oBd:destroy()
    RETURN
ENDIF

//  bd contains the decrypted content.

oCert:destroy()
oDecrypt:destroy()
oBd:destroy()