Skip to content

devmaster10/grammar-encrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grammar-encrypt

Laravel 5.x Database Encryption pm mysql side Use native mysql function AES_DECRYPT and AES_ENCRYPT What versions of Laravel are supported It have been tested only with Laravel 5.4. But you can try it with Laravel 5.x too.

Installation

How to install Add package to composer.json

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/devmaster10/grammar-encrypt.git"
    }
],
"require": {
    "laravel/framework": "5.0.*",
    "devmaster10/grammar-encrypt": "dev-master"
},

Updating your Eloquent Models

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

namespace App\Models;

use DevMaster10\GrammarEncrypt\Database\ModelEncrypt;

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

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 file

APP_GRAMMARENCRYPT_KEY=yourencryptedkey

About

Encryption on mysql side

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages