Skip to content
On this page

安全加密

AopCrypt 字符串可逆加密

使用的是支付宝支付包里面的加密


use JoyceZ\LaravelLib\Aop\AopCrypt;

$value='your string';
// withScrectKey 设置加密密钥,默认为空字符串
(new AopCrypt())->withScrectKey(env('APP_KEY'))->decrypt($value);
//使用配置文件中加密密钥
(new AopCrypt())->withScrectKey()->decrypt($value);
//自定义加密密钥
(new AopCrypt())->withScrectKey(config('laraveladmin.crypt.screct_key'))->decrypt($value);

数据库敏感字段可逆存储

TIP

EncryptTableDbAttribute Eloquent 模型属性加密和解密

  • 不支持模糊搜索,只支持精准搜索
  • 加解密是在 config('laraveladmin.crypt.screct_key') 进行配置
  • 依赖 JoyceZ\LaravelLib\Aop\AopCrypt 加密工具
use JoyceZ\LaravelLib\Traits\EncryptTableDbAttribute;

class Client extends Model {

    use EncryptTableDbAttribute;
   
    /**
     * 
     * @var array  需要加密解密的字段
     */
    protected $encryptTable = [
        'id_number', 
        'email',
    ];
}

根据 MIT 许可证发布。