asymmetricrypt / asymmetricrypt
A simple PHP public key cryptography library
Installs: 2 329
Dependents: 0
Suggesters: 0
Security: 1
Stars: 10
Watchers: 2
Forks: 3
Open Issues: 1
Requires
- php: >=5.3.0
- ext-openssl: *
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-12-07 15:48:12 UTC
README
Installation
Require asymmetricrypt/asymmetricrypt
in your project's composer.json
:
{ "require": { "asymmetricrypt/asymmetricrypt": "0.1.*" } }
Now update or install your packages with composer update
or composer install
respectively.
Usage
<?php use AsymmetriCrypt\Crypter; use AsymmetriCrypt\Key\PublicKey; use AsymmetriCrypt\Key\PrivateKey; // Create a private key $priv = Crypter::createPrivateKey(); // or $priv = PrivateKey::create(); // Load a private key $priv = Crypter::loadPrivateKey("file:///path/to/key.pem"); // or $priv = new PrivateKey("file:///path/to/key.pem"); // Get derived public key $pub = $priv->getPublicKey(); // Load a public key $pub = Crypter::loadPublicKey("file:///path/to/key.pub"); // or $pub = new PublicKey("file:///path/to/key.pub"); // Encrypt data $encrypted = Crypter::encrypt("data to encrypt", $pub); // Decrypt data $decrypted = Crypter::decrypt($encrypted, $priv); // Sign data $signature = Crypter::sign("data to sign", $priv); // Verify signature $signature_valid = Crypter::verify("data to sign", $signature, $pub);
Docs
I'm still working on a detailed documentation, but I don't have an ETA.