承接 tapanderasari/laravel-mysql-encrypt 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tapanderasari/laravel-mysql-encrypt

Composer 安装命令:

composer require tapanderasari/laravel-mysql-encrypt

包简介

Laravel Database encryption mysql side

README 文档

README

Total Downloads Latest Stable Version License

Laravel database encryption at database side using native AES_DECRYPT and AES_ENCRYPT functions. Automatically encrypt and decrypt fields in your Models.

Version Compatibility

Package Version Laravel PHP
3.x 13.x ^8.3
1.x 10–12 ^8.0

Install

1. Composer

composer require tapanderasari/laravel-mysql-encrypt

2. Publish config (optional)

php artisan vendor:publish --provider="TapanDerasari\MysqlEncrypt\Providers\LaravelServiceProvider"

3. Set encryption key in .env file

APP_AESENCRYPT_KEY=yourencryptionkey

Update Models

<?php

namespace App;

use TapanDerasari\MysqlEncrypt\Traits\Encryptable;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use Encryptable; // <-- 1. Include trait

    public array $encryptable = [ // <-- 2. Include columns to be encrypted
        'email',
        'first_name',
        'last_name',
        'telephone',
    ];
}

Schema

Encrypted columns must use VARBINARY (or BINARY/BLOB) in MySQL, not VARCHAR.

Schema::create('users', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('password');
    $table->binary('first_name', 300);  // VARBINARY(300)
    $table->binary('last_name', 300);
    $table->binary('email', 300);
    $table->binary('telephone', 50);
    $table->rememberToken();
    $table->timestamps();
});

Validators

unique_encrypted

unique_encrypted:<table>,<field(optional)>,<ignore_id(optional)>

exists_encrypted

exists_encrypted:<table>,<field(optional)>

Scopes

A global scope DecryptSelectScope is automatically applied to models using the Encryptable trait. It rewrites SELECT queries to wrap encrypted columns with AES_DECRYPT().

The following local scopes are available:

Exact match

User::whereEncrypted('email', 'john@example.com')->first();
User::whereNotEncrypted('email', 'john@example.com')->get();

OR conditions

User::whereEncrypted('email', 'a@b.com')
    ->orWhereEncrypted('email', 'c@d.com')
    ->get();

User::whereNotEncrypted('email', 'a@b.com')
    ->orWhereNotEncrypted('email', 'c@d.com')
    ->get();

LIKE search

User::whereEncryptedLike('first_name', 'John')->get();
User::orWhereEncryptedLike('first_name', 'Jane')->get();

Ordering

User::orderByEncrypted('first_name', 'asc')->get();
User::orderByEncryptedSort('last_name', 'desc')->get();

Implementing encryption for existing data

For this you can create one command like

php artisan make:command EncryptionForExistingData

In this command you fetch existing table or model data without global scope DecryptSelectScope.

You can refer the example, clicking on below Example button:

License

The MIT License (MIT). Please see License File for more information.

tapanderasari/laravel-mysql-encrypt 适用场景与选型建议

tapanderasari/laravel-mysql-encrypt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.8k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「mysql」 「encryption」 「laravel」 「pii」 「tapanderasari」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tapanderasari/laravel-mysql-encrypt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tapanderasari/laravel-mysql-encrypt 我们能提供哪些服务?
定制开发 / 二次开发

基于 tapanderasari/laravel-mysql-encrypt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-06