PHPackages                             codiant/dbaesencrypt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. codiant/dbaesencrypt

ActiveLibrary[Database &amp; ORM](/categories/database)

codiant/dbaesencrypt
====================

Laravel MySql AES Encrypt/Decrypt

05.3k↓100%PHP

Since Feb 11Pushed 5y agoCompare

[ Source](https://github.com/mahendrgurjar/mysql-aes-encrypt)[ Packagist](https://packagist.org/packages/codiant/dbaesencrypt)[ RSS](/packages/codiant-dbaesencrypt/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

- [Installation](#1install-the-package-via-composer)
- [Configure Provider](#2configure-provider)
- [Updating your Eloquent Models](#updating-your-eloquent-models)
- [Creating tables to support encrypt columns](#creating-tables-to-support-encrypt-columns)
- [Set encryption key in .env and config file](#set-encryption-key-in-env-and-config-file)

Laravel MySql AES Encrypt/Decrypt
=================================

[](#laravel-mysql-aes-encryptdecrypt)

Laravel 5.x Database Encryption in mysql side, use native mysql function AES\_DECRYPT and AES\_ENCRYPT
Auto encrypt and decrypt signed fields/columns in your Model
Can use all functions of Eloquent/Model
You can perform the operations "=&gt;, &lt;',' between ',' LIKE ' in encrypted columns

1.Install the package via Composer:
-----------------------------------

[](#1install-the-package-via-composer)

```
$ composer require codiant/dbaesencrypt
```

2.Configure provider
--------------------

[](#2configure-provider)

If you're on Laravel 5.4 or earlier, you'll need to add and comment line on config/app.php:

```
'providers' => array(
    // Illuminate\Database\DatabaseServiceProvider::class,
    DevMaster10\\AESEncrypt\\Database\\DatabaseServiceProviderEncrypt::class
)
```

Updating Your Eloquent Models
-----------------------------

[](#updating-your-eloquent-models)

Your models that have encrypted columns, should extend from ModelEncrypt:

```
namespace App\Models;

use DevMaster10\AESEncrypt\Database\Eloquent;

class Persons extends ModelEncrypt
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'tb_persons';

    /**
     * The attributes that are encrypted.
     *
     * @var array
     */
    protected $fillableEncrypt = [
        'name'
    ];

     /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
                'name',
                'description',
                ];
}
```

Creating tables to support encrypt columns
------------------------------------------

[](#creating-tables-to-support-encrypt-columns)

It adds new features to Schema which you can use in your migrations:

```
    Schema::create('tb_persons', function (Blueprint $table) {
        // here you do all columns supported by the schema builder
        $table->increments('id')->unsigned;
        $table->string('description', 250);
        $table ->unsignedInteger('created_by')->nullable();
        $table ->unsignedInteger('updated_by')->nullable();
    });

    // once the table is created use a raw query to ALTER it and add the BLOB, MEDIUMBLOB or LONGBLOB
    DB::statement("ALTER TABLE tb_persons ADD name MEDIUMBLOB after id");
```

});

Set encryption key in .env and config file
------------------------------------------

[](#set-encryption-key-in-env-and-config-file)

```
Set in .env file
APP_AESENCRYPT_KEY=yourencryptedkey

Set in config/services.php
'aesEncrypt' => [
    'key' => env('APP_AESENCRYPT_KEY'),
]
```

Add BaseUser class for fixed problem of authenticable model problem
-------------------------------------------------------------------

[](#add-baseuser-class-for-fixed-problem-of-authenticable-model-problem)

```
Create BaseUser class in app/BaseUser.php for fixed problem of authenticable model problem

```

```
namespace App;

use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use DevMaster10\AESEncrypt\Database\Eloquent;

class BaseUser extends Eloquent\ModelEncrypt implements
    AuthenticatableContract,
    AuthorizableContract,
    CanResetPasswordContract
{
    use Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
}
```

Extends BaseUser class in your Authenticatable model.

```

```

###  Health Score

21

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/074b299618b43ae6a89f7fb2ef7f5985dff5c9b15c58f8adc404c4e7e1e8fd1f?d=identicon)[mgurjar](/maintainers/mgurjar)

---

Top Contributors

[![devmaster10](https://avatars.githubusercontent.com/u/38945076?v=4)](https://github.com/devmaster10 "devmaster10 (20 commits)")[![MarshallDez](https://avatars.githubusercontent.com/u/210487023?v=4)](https://github.com/MarshallDez "MarshallDez (14 commits)")[![mahendrgurjar](https://avatars.githubusercontent.com/u/66988706?v=4)](https://github.com/mahendrgurjar "mahendrgurjar (11 commits)")

### Embed Badge

![Health badge](/badges/codiant-dbaesencrypt/health.svg)

```
[![Health](https://phpackages.com/badges/codiant-dbaesencrypt/health.svg)](https://phpackages.com/packages/codiant-dbaesencrypt)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k280.5M5.6k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k114.4M86](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k51.5M8.2k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k62.7M499](/packages/mongodb-mongodb)[spatie/laravel-translatable

A trait to make an Eloquent model hold translations

2.4k22.1M350](/packages/spatie-laravel-translatable)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.5k23.2M26](/packages/kirschbaum-development-eloquent-power-joins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
