2017 © Pedro Peláez
 

library aesencrypt

Laravel MySql AES Encrypt/Decrypt

image

devmaster10/aesencrypt

Laravel MySql AES Encrypt/Decrypt

  • Friday, May 18, 2018
  • by devmaster10
  • Repository
  • 0 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 150 % Grown

The README.md

Laravel MySql AES Encrypt/Decrypt

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 "=>, <',' between ',' LIKE ' in encrypted columns
, (*1)

1.Install the package via Composer:

$ composer require devmaster10/aesencrypt:dev-master

2.Configure provider

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

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

Updating Your Eloquent Models

Your models that have encrypted columns, should extend from ModelEncrypt:, (*3)

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

It adds new features to Schema which you can use in your migrations:, (*4)

    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");  

});, (*5)

Set encryption key in .env file

APP_AESENCRYPT_KEY=yourencryptedkey

The Versions

18/05 2018

dev-master

9999999-dev https://github.com/Seldaek/monolog

Laravel MySql AES Encrypt/Decrypt

  Sources   Download

Apache-2.0

The Requires

 

by Marcelo Barros

laravel mysql encrypt aes