php-privacy / openpgp
PHP Privacy - The OpenPGP library in PHP language
1.1.7
2024-03-27 09:33 UTC
Requires
- php: ^8.1
- phpseclib/phpseclib: ^3.0
- psr/log: ^3.0
Requires (Dev)
- fakerphp/faker: ^1.0
- monolog/monolog: ^3.0
- phpunit/phpunit: ^9.0 | ^10.0
README
PHP Privacy is an implementation of the OpenPGP standard in PHP language. It implements RFC4880, RFC5581, RFC6637, parts of RFC4880bis.
Requirement
- PHP 8.1.x or later,
- phpseclib library provides cryptography algorithms,
- (optional) PHPUnit to run tests,
Features
- Support data signing & encryption.
- Support key management: key generation, key reading, key decryption.
- Support public-key algorithms: RSA, DSA, ElGamal, ECDSA, EdDSA and ECDH.
- Support symmetric ciphers: TripleDES, IDEA, CAST5, Blowfish, Twofish, AES, Camellia.
- Support AEAD algorithms: EAX, OCB, GCM.
- Support hash algorithms: MD5, SHA-1, RIPEMD-160, SHA-256, SHA-384, SHA-512, SHA-224.
- Support compression algorithms: Zip, Zlib, BZip2.
- Support ECC curves: secP256k1, secP384r1, secP521r1, brainpoolP256r1, brainpoolP384r1, brainpoolP512r1, curve25519, ed25519, prime256v1.
Installation
Via Composer
$ composer require php-privacy/openpgp
or just add it to your composer.json
file directly.
{ "require": { "php-privacy/openpgp": "*" } }
Basic usage of PHP Privacy
Sign and verify cleartext message
<?php declare(strict_types=1); require_once 'vendor/autoload.php'; use OpenPGP\OpenPGP; $armoredPublicKey = '-----BEGIN PGP PUBLIC KEY BLOCK-----'; $armoredPrivateKey = '-----BEGIN PGP PRIVATE KEY BLOCK-----'; $passphrase = 'Your passphrase'; $publicKey = OpenPGP::readPublicKey($armoredPublicKey); $privateKey = OpenPGP::decryptPrivateKey($armoredPrivateKey, $passphrase); $cleartextMessage = OpenPGP::createCleartextMessage('Hello, PHP Privacy!'); $signedMessage = $cleartextMessage->sign([$privateKey]); $verifications = $signedMessage->verify([$publicKey]);
Licensing
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.