Download the PHP package chuyubo/field_encryption without Composer

On this page you can find all versions of the php package chuyubo/field_encryption. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package field_encryption

基于laravel实现数据库敏感字段加密

原理:

1.替代db.factory ,将对应的 factory 指向自定义 FieldEncryptionConnectionFactory, 将对应的mysqlConnection 指向自定义FieldEncryptionMysqlConnection,最终将Builder替换成自定义FieldBuilder

2.改写 FieldBuilder 中get,insert,update 等方法,将需要加密的字段进行加密,读取时将加密字段进行解密

注意:

并不是所有写法都适合,比如Raw,whereRaw等原生写法,也不支持sql函数对该字段进行处理,当相关业务涉及到上述写法,建议修改写法或者加字段加密成加密字段再添加

加密:
//$rule => 配置保留前置位数和加密
$rule = ['pre_len' => 0, 'encryption_field_len' => 20000];
/** @var \FieldEncryption\Utils\EncryptionUtils $encryption */
$encryption = app(\FieldEncryption\Utils\EncryptionUtils::class);
$value = $encryption->encryptionAes($value, $rule['pre_len'], $rule['encryption_field_len']);
解密:
/** @var \FieldEncryption\Utils\DecryptUtils $decrypt */
$decrypt = app(\FieldEncryption\Utils\DecryptUtils::class);
$value = $decrypt->decryptAes($value);

使用方法:

1.在laravel中app/config/app.php 中 providers 添加

 \FieldEncryption\Providers\DatabaseServiceCustomProvider::class,
 \FieldEncryption\Providers\FieldEncryptionProvider::class,

注意要放到 Illuminate\Database\DatabaseServiceProvider::class下面的位置,相当于覆盖

2.将 vendor/chuyubo/field_encryption/config/field_encryption.php 复制到app/config/文件夹下

aes_key 加密密钥,保证不进行修改
aes_pre 加密后的字段前缀标识,不要为空
aes_tail 加密后的字段后缀标识,不要为空
table_tmp 临时表后缀,要复杂不要与原表名后缀一样,不要为空
table_tmp_switch 临时表开关,true|false,跑同步脚本的时候需要打开,其他情况下关闭
field 表字段配置 二维数组,内容如下
[
    [
        'table' => '', //table 表名称
        'column' => '', //加密列
        'rule' => '', //加密规则,与下面rules 相对应
    ]
]
rules 加密规则:
[
    //键值对应field中的rule
    'default' => [
        'pre_len' => 0, //加密字段前置保留位数,适配一些模糊查询
        'tail_len' => 0, //加密字段后置保留位数,目前并不管用
        'encryption_field_len' => 20000, //加密位数,目前根据前置位数+加密位数来决定加密成什么样子
    ],
]

3.将数据同步成加密数据的加密脚本

php artisan sys:filed-encryption

可以根据自己的需求改写,脚本所在位置
vendor/chuyubo/field_encryption/src/Command/SysCommand.php
原理:生成临时表进行插入加密后的数据然后关联替换

4.最终加密后效果:

field_NResPuJT+vjlfgspUqNINah5PsJwwJ2yA6shz9WsSSS=encryption0,0
解析:'field
'为前置加密标识,'_encryption'为后置加密标识, 0,0 前置保留位数0,后置保留位数0


All versions of field_encryption with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
illuminate/database Version ^6.0
ext-openssl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package chuyubo/field_encryption contains the following files

Loading the files please wait ...