Sample code for 30+ languages & platforms
PHP Extension

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$cert = new CkCert();

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

$decrypt = new CkCrypt2();
$decrypt->put_CryptAlgorithm('pki');

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

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

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

// bd contains the decrypted content.

?>