blackplatinum / encryption
BlackPlatinum 加密组件。
v1.0.0
2020-11-15 17:18 UTC
Requires
- php: ^7.3 || ^8.0
- ext-json: *
- ext-openssl: *
- ext-redis: *
- baha2rmirzazadeh/phpscanner: ^1.5
- symfony/console: ^5.0
This package is auto-updated.
Last update: 2024-09-16 05:42:20 UTC
README
特性
支持的加密算法:AES-128-CBC, AES-192, AES-256-CBC, CAST5-CBC, BlowFish-CBC
控制台应用程序
由于需要设置加密密钥、测试系统等,为此设计了该组件的命令行界面。
部分命令
- [php guard key:set]
- [php guard key:generate]
- [php guard fresh]
如何使用控制台应用程序?
要使用控制台应用程序,只需在 guard
所在的终端中输入:php guard
。所有命令均有文档说明并可操作。
安装
使用 [Composer] 安装包
$ composer require blackplatinum/encryption
示例
use BlackPlatinum\Encryption\Crypto\Symmetric\Crypto; use BlackPlatinum\Encryption\KeyManager\KeyManager; $cipher = (new Crypto('CAST5-CBC'))->setKey(KeyManager::getKey())->encrypt( [ 'Name' => 'John', 'LastName' => 'LastName', 'Age' => 22, 'IsStudent' => true, 'Courses' => ['Math', 'Economy', 'Chemistry'] ] ); print $cipher; $plainText = (new Crypto('BF-CBC'))->setKey(KeyManager::getKey())->decrypt('eyJpdiI6Ik05RE9...'); print_r($plainText); use BlackPlatinum\Encryption\Crypto\Asymmetric\Crypto; $crypto = new Crypto(); $cipher = $crypto->publicKeyEncrypt( [ 'Name' => 'John', 'LastName' => 'LastName', 'Age' => 22, 'IsStudent' => true, 'Courses' => ['Math', 'Economy', 'Chemistry'] ], KeyManager::getRSAPublicKey() ); print $cipher . "\n"; print_r($crypto->privateKeyDecrypt($cipher, KeyManager::getRSAPrivateKey()));
类和方法描述
所有类和方法都有文档,您可以阅读它们并了解它们的工作原理。
作者
- [BlackPlatinum 开发者]
- 电子邮件:[blackplatinum2019@gmail.com]
许可协议
本组件所有内容均受 [MIT 许可协议] 授权。