Sample code for 30+ languages & platforms
PHP

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\BinData;
use Chilkat2\Cert;
use Chilkat2\Crypt2;

$cert = new Cert();

try {
    $cert->LoadPfxFile('c:/pfx_files/my.pfx', 'password');

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

    $decrypt->SetDecryptCert($cert);

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

    $decrypt->DecryptBd($bd);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

// bd contains the decrypted content.