Sample code for 30+ languages & platforms
Unicode C++

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkCertW.h>
#include <CkCrypt2W.h>
#include <CkBinDataW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCertW cert;

    success = cert.LoadPfxFile(L"c:/pfx_files/my.pfx",L"password");
    if (success != true) {
        wprintf(L"%s\n",cert.lastErrorText());
        return;
    }

    CkCrypt2W decrypt;
    decrypt.put_CryptAlgorithm(L"pki");

    success = decrypt.SetDecryptCert(cert);
    if (success != true) {
        wprintf(L"%s\n",decrypt.lastErrorText());
        return;
    }

    CkBinDataW bd;
    success = bd.LoadFile(L"c:/someDir/pkcs7_encrypted.dat");

    success = decrypt.DecryptBd(bd);
    if (success != true) {
        wprintf(L"%s\n",decrypt.lastErrorText());
        return;
    }

    //  bd contains the decrypted content.
    }