arzeroid/laravel-model-ssh-encryptable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arzeroid/laravel-model-ssh-encryptable

Composer 安装命令:

composer require arzeroid/laravel-model-ssh-encryptable

包简介

A simple trait to encrypt attributes using public key before saving to the database and to decrypt attributes using private key before using their values

README 文档

README

A simple trait to encrypt attributes using public key before saving to the database and to decrypt attributes using private key before using their values

Installation

Simply add the following line to your composer.json and run composer update

"arzeroid/laravel-model-ssh-encryptable": "^1.0",

Or use composer to add it with the following command

composer require "arzeroid/laravel-model-ssh-encryptable"

Usage

  1. Add the trait to your model and set your attributes to be encrypted in encryptable array
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Arzeroid\LaravelModelEncryptable\SSHEncryptable;

class UserSalary extends Model
{
    ...
    use SSHEncryptable;

    /**
     * The attributes that should be encrypted.
     *
     * @var array
     */
    protected $encryptable = [
        'payroll',
    ];
    ...
}
  1. Set PUBLIC_KEY variable in .env file for public key
PUBLIC_KEY=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDL/6Kf7FxMR68WllFaKMfFLOmScFZFUOvjRaKuVOdOt6t+sqPUxqcXbPakvtqEY/RcavVs7Of8ae3qSIiwxgialtGVfMzTMU39GlmAkKZ97HCvZ+DX0lMHZ0EXghBqnn0gm7+5GsiHJZ/ImFiPJkeA74F/3y6cppkgpIgGQrH5wQIDAQAB
  1. Set private_key key in cache for private key
<?php

namespace App\Http\Controllers;

use Cache;
...

class UserSalaryController extends Controllers
{
    ...
    public function setKey()
    {
        Cache::forever('private_key', 'MIICXQIBAAKBgQDL/6Kf7FxMR68WllFaKMfFLOmScFZFUOvjRaKuVOdOt6t+sqPUxqcXbPakvtqEY/RcavVs7Of8ae3qSIiwxgialtGVfMzTMU39GlmAkKZ97HCvZ+DX0lMHZ0EXghBqnn0gm7+5GsiHJZ/ImFiPJkeA74F/3y6cppkgpIgGQrH5wQIDAQABAoGBAJDEPPgYl/dZ95qj2d+NiRcYJDlTlyVho8SJKkVk4zEtjno+85yPzQwGu5F2D0RcWpErJjfCd27dDYVxK++m2Xr1URVhaG9Y7NRIso2gRayG8AbwIRUu1WrRt6Kyll/Dnveoxbw/WyccmS/CicBG52G+egDubgaTcvFiaRRaABRBAkEA+l+bSevcsDNtsPEBwrdQhzr5wR82JTuGO7/HIb2s0GpPR8KnoLtHChhiBHMxINTCkHwi7AN4iUTfUK4y7d1npQJBANCVPCDKzxXJ1isVGfhBldJvyDB/xPLwkXIf3Hwaig1nSBfUFnJe8dBb2QFcF+QoyFXAvLPZ7ydiAvzpT492Du0CQQCEfzf0xKcDcBPqgYBHBS/OgL1PIC9NQNTmpbTB/FiJ6tiNx0tiWflcNE8av8MN9soIIEly0Ntm+VWcorM9AeApAkBsRkukKiM9iDyouJd2i3Uee/BLXMf75G1b9LYbphsrwgVmeS39yNN1+Xe4gPnV8mWsPhS2t9axduteJi6qpfoxAkBXBkgvBnWFaNs6fZVANE2GKdI9F5pF3Cm2eUy+90pmrwM5o2Jfiy6aRXQ9689XKNV2LSXXuP7yjQFj8mqiCD7q');
        ...
    }
}

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固