Sample code for 30+ languages & platforms
PHP ActiveX

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

$cert = new COM("Chilkat.Cert");

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

$decrypt = new COM("Chilkat.Crypt2");
$decrypt->CryptAlgorithm = 'pki';

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

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

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

// bd contains the decrypted content.

?>