Sample code for 30+ languages & platforms
JavaScript

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

var cert = new CkCert();

success = cert.LoadPfxFile("c:/pfx_files/my.pfx","password");
if (success !== true) {
    console.log(cert.LastErrorText);
    return;
}

var decrypt = new CkCrypt2();
decrypt.CryptAlgorithm = "pki";

success = decrypt.SetDecryptCert(cert);
if (success !== true) {
    console.log(decrypt.LastErrorText);
    return;
}

var bd = new CkBinData();
success = bd.LoadFile("c:/someDir/pkcs7_encrypted.dat");

success = decrypt.DecryptBd(bd);
if (success !== true) {
    console.log(decrypt.LastErrorText);
    return;
}

// bd contains the decrypted content.