Sample code for 30+ languages & platforms
Perl

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $cert = Chilkat2::Cert->new;

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

my $decrypt = Chilkat2::Crypt2->new;
$decrypt->CryptAlgorithm('pki');

$success = $decrypt->SetDecryptCert($cert);
if (!$success) {
    print $decrypt->LastErrorText, "\n";
    exit;
}

my $bd = Chilkat2::BinData->new;
$success = $bd->LoadFile('c:/someDir/pkcs7_encrypted.dat');

$success = $decrypt->DecryptBd($bd);
if (!$success) {
    print $decrypt->LastErrorText, "\n";
    exit;
}

# bd contains the decrypted content.