maxcrossan/yii_encryption
Composer 安装命令:
composer require maxcrossan/yii_encryption
包简介
A simple encryption behaviour for encrypting and decrypting database fields on Yii models
README 文档
README
A simple encryption behaviour for encrypting and decrypting database fields on Yii models. After implementation fields configured for encryption will be encrypted the next time the model is saved.
Installation
Add the following to your composer file and run php composer.phar update
"require": { "maxcrossan/yii_encryption": "dev-master" },
Configure the Yii securityManger component in protected/config/main.php
'components'=>array( 'securityManager'=>array( 'cryptAlgorithm' => 'rijndael-128', 'encryptionKey' => 'your-encryption-key' ) )
Usage
Simply add the following to your model behaviours along with the database columns you want to encrypt:
public function behaviors(){ return array( 'EncryptionBehaviour'=>array( 'class'=>'application.vendor.maxcrossan.yii_encryption.src.EncryptionBehaviour', //Add the fields you wish to encrypt below 'encryptedFields'=>array( 'addressLine1', 'addressLine2', 'lastName', 'city', 'postcode', 'emailAddress', 'phone' ) ) ) }
Any encrypted database columns are best setup with the BLOB db type
Troubleshooting
If you have problems loading the class inside your models you may need to setup an alias for vendor in main.php, something like Yii::setPathOfAlias('vendor',dirname(__FILE__).'/../../vendor/'); and then reference the EncryptionBehaviour as vendor.maxcrossan.yii_encryption.src.EncryptionBehaviour
统计信息
- 总下载量: 49
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-18