leolopez/encrypt

Encrypts any field from a model, array or value.

1.1.2 2022-04-16 22:59 UTC

This package is auto-updated.

Last update: 2024-04-17 03:10:12 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Installation

Install the package

composer require leolopez/encrypt

Register the service provider

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,

Available methods

Models

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)

Arrays

Encrypts columns of an Array

encryptArray($array, $keys)

Decrypts columns of an Array

decryptArray($array, $keys)    

Values

Encrypts a value

encryptValue($value)

Decrypts a value

decryptValue($key)

Example

Encrypt a model value

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']);

Decrypt a model value

Send as a first parameter the array, and add the keys you want to decrypt

$users = User::all();
$users = Encrypt::encryptObject($users, ['id']);