Sample code for 30+ languages & platforms
Perl

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat Perl Downloads

Perl
use chilkat();

$success = 0;

$cert = chilkat::CkCert->new();

$success = $cert->LoadPfxFile("c:/pfx_files/my.pfx","password");
if ($success != 1) {
    print $cert->lastErrorText() . "\r\n";
    exit;
}

$decrypt = chilkat::CkCrypt2->new();
$decrypt->put_CryptAlgorithm("pki");

$success = $decrypt->SetDecryptCert($cert);
if ($success != 1) {
    print $decrypt->lastErrorText() . "\r\n";
    exit;
}

$bd = chilkat::CkBinData->new();
$success = $bd->LoadFile("c:/someDir/pkcs7_encrypted.dat");

$success = $decrypt->DecryptBd($bd);
if ($success != 1) {
    print $decrypt->lastErrorText() . "\r\n";
    exit;
}

# bd contains the decrypted content.