A simple trait to make attributes encrypted in the database
gregoryduckworth/encryptable is a Laravel package for a simple trait to make attributes encrypted in the database.
It currently has 19 GitHub stars and 54.009 downloads on Packagist (latest version 1.0.2).
Install it with composer require gregoryduckworth/encryptable.
Discover more Laravel packages by gregoryduckworth
or browse all Laravel packages to compare alternatives.
Last updated
Encryptable is a trait for Laravel that adds simple encryptable functions to Eloquent Models.
Encryptable allows you to encrypt data as in enters the database and decrypts it on its retrieval.
Simple add the package to your composer.json file and run composer update.
"gregoryduckworth/encryptable": "1.*",
Add the trait to your model and your encryptable rules.
use GregoryDuckworth\Encryptable\EncryptableTrait;
class User extends Authenticatable
{
use EncryptableTrait;
/**
* Encryptable Rules
*
* @var array
*/
protected $encryptable = [
'name',
'email',
];
...
}
Now, whenever you interact with the model, the name and email will automatically be encrypted and decrypted between your frontend and the database.
Anyone is welcome to contribute. Fork, make your changes and then submit a pull request.