1. Go to this page and download the library: Download zbateson/mmp-crypt-smime library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zbateson / mmp-crypt-smime example snippets
use ZBateson\MailMimeParser\Message;
use ZBateson\MmpCryptSmime\SMimeMessage;
$message = Message::from($rawEmail, false);
$cert = file_get_contents('/path/to/recipient-cert.pem');
// Encrypt -- returns a new IMimePart with application/pkcs7-mime content
$encrypted = SMimeMessage::encrypt($message, $cert);
// The outer Subject defaults to "..." to hide the real subject
echo (string) $encrypted;
use ZBateson\MmpCryptSmime\SMimeOpenSsl;
// Configure the decryption credentials
$crypt = new SMimeOpenSsl(
decryptionCredentials: [
['cert' => $cert, 'key' => $key],
],
);
// Decrypt the content stream from a parsed encrypted part
$decrypted = $crypt->decrypt($encryptedPart->getContentStream());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.