mazfreelance / yii2-laravel-crypt
此包已废弃,不再维护。未建议替代包。
yii2-laravel-crypt 是与 Laravel 兼容的 yii2 库
v1.1.4
2021-12-08 10:32 UTC
Requires
- php: >=5.5
- paragonie/random_compat: 2.0.*
README
这与 Laravel(>=5.1) 的加密和解密函数相同。
变更日志
有关上次版本以来的更改,请参阅 变更日志。
安装
composer require mazfreelance/yii2-laravel-crypt -W
配置
添加您的本地参数
'encrypter' => [
'key' = '',
'cipher' = ''
]
用法
1) 单次使用或
use Cryption\Encrypter;
$cryption = Encrypter("yourRandomString","AES-256-CBC");
$cryption->encrypt("yourData");`
2) 此行为用于在数据库中存储数据之前加密数据,并在检索时解密数据。
- 在模型类中添加以下代码
public function behaviors()
{
return [
'encryption' => [
'class' => '\Cryption\EncryptionBehavior',
'attributes' => [
'attribute1',
'attribute2',
],
],
];
}