browomir/open-encryption
Composer 安装命令:
composer require browomir/open-encryption
包简介
Simple users password encryption class based on OpenSSL
README 文档
README
Simple password encryption class based on OpenSSL.
Prerequisites
- PHP 5.4 or later
Installation
The preferred way to install this class is through composer.
Either run
php composer.phar require browomir/open-encryption "dev-master"
or add
// composer.json { "require": { "browomir/open-encryption": "dev-master" } }
to the require section of your composer.json file.
Usage
This simple example show how you can use this class:
require_once 'vendor/autoload.php'; use OpenEncryption\Encryption; $username = 'test@example.com'; $password = 'test123'; $salt = 'somesalt'; $encryption = new Encryption(); // you can pass secret key as constructor parameter // e.g. $encryption = new Encryption('mySecret'); $encrypted = $encryption->encrypt($password, $salt, $username); $decrypted = $encryption->decrypt($encrypted, $salt, $username); echo 'Encrypted: ' . $encrypted; echo '<br>'; echo 'Decrypted: ' . $decrypted;
Additional:
- if you don't want use default cipher method (AES-256-CBC) you can set your own:
$cipher = new Cipher('AES-128-ECB'); $encryption->setCipher($cipher);
- you can check if chosen cipher is supported and/or is strong:
if ($cipher->isSupported() && $cipher->isCryptoStrong()) { echo 'Your cipher is good!'; } else { echo 'You should chose other cipher!'; }
- you can get list of all supported cipher by:
$cipher->getSupportedCiphers();
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-05