A simple PHP public key cryptography library

0.3.0 2013-02-05 16:09 UTC

This package is not auto-updated.

Last update: 2020-06-26 17:19:04 UTC


Build Status


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.



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/");
// or
$pub = new PublicKey("file:///path/to/");

// 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);


I'm still working on a detailed documentation, but I don't have an ETA.

Bitdeli Badge