lancerhe / php-crypt
There is no license information available for the latest version (v1.1.0) of this package.
PHP encryption class library
v1.1.0
2016-08-21 03:41 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2024-11-05 16:24:46 UTC
README
Crypt for AES, RSA, 3DES and some special algorithms.
Requirements
PHP5.3.0 or later
Installation
Create or modify your composer.json
{
"require": {
"lancerhe/php-crypt": "1.1.0"
}
}
Usage
AES
require('./vendor/autoload.php');
$key = 'nh9a6d2b6s6g9ynh';
$iv = 'ddky2235gee1g3mr';
$source = 'my message';
$crypt = new \LancerHe\Crypt\AES();
$encrypt = $crypt->encrypt($source, $key, $iv);
var_dump($encrypt); // S5r5uy5zA7yTGIMj0rk68A==
$decrypt = $crypt->decrypt($encrypt, $key, $iv);
var_dump($source); // my message
3DES
require('./vendor/autoload.php');
$key = '6d2b6s6g';
$iv = '2235gee1';
$source = 'my message';
$crypt = new \LancerHe\Crypt\TripleDES();
$encrypt = $crypt->encrypt($source, $key, $iv);
var_dump($encrypt); // JPZDDBXGOXZc949A+ggNlA==
$decrypt = $crypt->decrypt($encrypt, $key, $iv);
var_dump($source); // my message
RSA
require('./vendor/autoload.php');
$crypt = new \LancerHe\Crypt\RSA('/tmp/');
$encrypt = $crypt->pubEncrypt('new message');
var_dump($encrypt); // rand base64_encode
$decrypt = $crypt->privDecrypt($encrypt);
var_dump($decrypt); // new message
Id
require('./vendor/autoload.php');
$crypt = new \LancerHe\Crypt\Id();
$encrypt = $crypt->encrypt(23123123);
var_dump($encrypt); // w6lt46urq
$decrypt = $crypt->decrypt($encrypt);
var_dump($encrypt); // 23123123