Download the PHP package sagalbot/encryptable without Composer
On this page you can find all versions of the php package sagalbot/encryptable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sagalbot/encryptable
More information about sagalbot/encryptable
Files in sagalbot/encryptable
Package encryptable
Short Description Allows you to store Eloquent properties encrypted in your database, and automatically decrypt when accessed.
License MIT
Informations about the package encryptable
Encryptable Eloquent Model Properties
A Laravel 5 package that allows you to store Eloquent model properties encrypted in your database, and automatically decrypts them when you need to access them.
Install
Usage
This package is really just a simple trait and property that you can add to your Eloquent models. Usage is simple:
-
Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file.
note: If you already have
APP_KEY
set in your.env
, you should skip this step. -
Use the
Sagalbot\Encryptable\Encryptable
trait: -
Set the
$encryptable
array on your Model. - That's it! Here's a complete example:
Encryption Options
By default, the package uses the global encrypt()
and decrypt()
Laravel functions, which are just aliases to resolve the Illuminate\Encryption\Encrypter::class
out of the container. Laravel's encrypter uses OpenSSL to provide AES-256 and AES-128 encryption, which you can read more about at the Laravel Docs.
If you need to adjust how a specific model encrypts and decrypts its properties, you can override the decryptAttribute
and encryptAttribute
methods on your model:
Keep It Secret, Keep It Safe
Don't lose your encryption key - you can't decrypt your stored data without it.