C++
C++
Example: Crypt2.SetDecryptCert method
Demonstrates how to call the SetDecryptCert method.Chilkat C++ Downloads
#include <CkCert.h>
#include <CkCrypt2.h>
#include <CkBinData.h>
void ChilkatSample(void)
{
bool success = false;
CkCert cert;
success = cert.LoadPfxFile("c:/pfx_files/my.pfx","password");
if (success != true) {
std::cout << cert.lastErrorText() << "\r\n";
return;
}
CkCrypt2 decrypt;
decrypt.put_CryptAlgorithm("pki");
success = decrypt.SetDecryptCert(cert);
if (success != true) {
std::cout << decrypt.lastErrorText() << "\r\n";
return;
}
CkBinData bd;
success = bd.LoadFile("c:/someDir/pkcs7_encrypted.dat");
success = decrypt.DecryptBd(bd);
if (success != true) {
std::cout << decrypt.lastErrorText() << "\r\n";
return;
}
// bd contains the decrypted content.
}