Install the package
composer require leolopez/encrypt
Add the Service Provider in config/app.php
into the providers
section
Leolopez\Encrypt\EncryptServiceProvider::class
Add the Facade in config/app.php
into the aliases
section
'Encrypt' => Leolopez\Encrypt\Facades\Encrypt::class,
Encrypts columns of an array of object
encryptObject($array, $keys)
Decrypts columns of an array of object
decryptObject($array, $keys)
Encrypts a column of an Object
encryptValueObject($object, $key)
Decrypts a column of an Object
decryptValueObject($object, $key)
Encrypts columns of an Array
encryptArray($array, $keys)
Decrypts columns of an Array
decryptArray($array, $keys)
Encrypts a value
encryptValue($value)
Decrypts a value
decryptValue($key)
Go to your controller and import the facade
use Leolopez\Encrypt\Facades\Encrypt;
Send as a first parameter the array, and add the keys you want to encrypt
$users = User::all();
$users = Encrypt::encryptObject($users, ['id']);
Send as a first parameter the array, and add the keys you want to decrypt
$users = User::all();
$users = Encrypt::encryptObject($users, ['id']);