jdz / crypt
Simple Crypt/Decrypt utility
2.0.1
2018-05-29 22:06 UTC
Requires
- php: ^7.1.3
This package is auto-updated.
Last update: 2024-12-24 08:44:30 UTC
README
Simple crypt/decypt utility
Usage
use JDZ\Crypt\Crypt;
use JDZ\Crypt\CryptCipher;
use JDZ\Crypt\CryptKey;
$privateKey = md5('oiuoiupoiupo'.@$_SERVER['HTTP_USER_AGENT']);
$clean = 'Test value';
// encrypt
$key = new CryptKey($privateKey, $privateKey);
$cipher = new CryptCipher();
$crypt = new Crypt($cipher, $key);
$crypted = $crypt->encrypt($clean);
echo "\n";
echo 'Encrypt'."\n";
echo 'Clear value : '.$clean."\n";
echo 'Crypted value : '.$crypted."\n";
// decrypt
$key = new CryptKey($privateKey, $privateKey);
$cipher = new CryptCipher();
$crypt = new Crypt($cipher, $key);
$decrypted = $crypt->decrypt($crypted);
echo "\n";
echo 'Decrypt'."\n";
echo 'Crypted value : '.$crypted."\n";
echo 'Clear value : '.$decrypted."\n";