zbateson/mmp-crypt-gpg
最新稳定版本:1.0.0
Composer 安装命令:
composer require zbateson/mmp-crypt-gpg
包简介
PGP/MIME implementation of zbateson/mmp-crypt using PEAR Crypt_GPG
README 文档
README
PGP/MIME encryption, decryption, signing, and verification for zbateson/mail-mime-parser using PEAR's Crypt_GPG.
composer require zbateson/mmp-crypt-gpg
Sponsors
A huge thank you to all my sponsors. <3
If this project's helped you, please consider sponsoring me.
Requirements
PHP 8.1 or newer with the gpg binary available on the system, and zbateson/mail-mime-parser 4.x. A configured GnuPG keyring with the appropriate keys imported is also required — see the GnuPG documentation for details on setting up your keyring.
Description
This package provides a PGP/MIME implementation of zbateson/mmp-crypt using PEAR's Crypt_GPG. It supports:
- Encrypting and decrypting
multipart/encrypted; protocol="application/pgp-encrypted"messages - Signing and verifying detached
application/pgp-signaturesignatures - Composing PGP/MIME messages via the
PgpMimeMessagestatic API (encrypt, sign, sign-then-encrypt)
All operations use file-based I/O via temp files, so large messages are handled without loading them entirely into memory.
Usage
Composing an encrypted message
use ZBateson\MailMimeParser\Message; use ZBateson\MmpCryptGpg\GpgPear; use ZBateson\MmpCryptGpg\PgpMimeMessage; $message = Message::from($rawEmail, false); $cryptGpg = new \Crypt_GPG(); $cryptGpg->addEncryptKey('recipient@example.com'); $crypt = new GpgPear($cryptGpg); // Encrypt -- returns a new IMimePart with multipart/encrypted structure $encrypted = PgpMimeMessage::encrypt($message, $crypt); // The outer Subject defaults to "..." to hide the real subject echo (string) $encrypted;
Composing a signed message
$cryptGpg = new \Crypt_GPG(); $cryptGpg->addSignKey('sender@example.com'); $crypt = new GpgPear($cryptGpg); $signed = PgpMimeMessage::sign($message, $crypt);
Sign-then-encrypt
$cryptGpg = new \Crypt_GPG(); $cryptGpg->addSignKey('sender@example.com'); $cryptGpg->addEncryptKey('recipient@example.com'); $crypt = new GpgPear($cryptGpg); $result = PgpMimeMessage::signAndEncrypt($message, $crypt);
Decrypting a parsed message
use ZBateson\MmpCryptGpg\GpgPear; $cryptGpg = new \Crypt_GPG(); // Keys must be in the GnuPG keyring for decryption $crypt = new GpgPear($cryptGpg); $decrypted = $crypt->decrypt($encryptedPart->getContentStream());
License
BSD licensed - please see license agreement.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2026-02-13