asymmetricrypt/asymmetricrypt

A simple PHP public key cryptography library

0.3.0 2013-02-05 16:09 UTC

README

Build Status

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.

Bitdeli Badge