crisjohn02 / encrypter
Column encrypter
Installs: 32
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/crisjohn02/encrypter
Requires
- php: ^7.1.3
This package is auto-updated.
Last update: 2025-12-07 04:25:42 UTC
README
What this package is all about?
This package will automatically encrypt when storing and decrypt when retrieving eloquent using the laravel encryption method. This can be useful when someone illegally downloaded the database and will render the data useless. The salt is user specific so all data cannot be decrypted in just one salt value. Please note that once you lose the salt values the encrypted data cannot be decrypted again, so be careful when using this package.
Installation
composer require crisjohn02/encrypter
Usage
Create your user table with a salt column.
Schema::create('users', function(Blueprint $table) { $table->string('salt'); });
To automatically create salt values, add trait HasSalt into your User model
<?php namespace App\YourNameSpace; use Illuminate\Database\Eloquent\Model; use Crisjohn02\Encrypter\Traits\HasSalt; class User extends Model { use HasSalt; }
In your eloquent model, add trait Encryptable
<?php namespace App\YourNameSpace; use Illuminate\Database\Eloquent\Model; use Crisjohn02\Encrypter\Traits\Encryptable; class Post extends Model { use Encryptable; //Specify the encryptable columns protected $encryptables = [ 'title', 'user_id' ]; }
You can also use the HasUuid trait and make sure your model has uuid column
<?php namespace App\YourNameSpace; use Illuminate\Database\Eloquent\Model; use Crisjohn02\Encrypter\Traits\HasUuid; class Post extends Model { use HasUuid; }
Limitation
Do not use Encryptable trait in your user model, this will cause an error when creating new user.