Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/betterapp/laravel-db-encrypter
https://github.com/betterapp/laravel-db-encrypter
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/betterapp/laravel-db-encrypter
- Owner: betterapp
- License: mit
- Created: 2020-01-12T10:23:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-02T08:23:09.000Z (over 1 year ago)
- Last Synced: 2024-05-17T05:01:54.425Z (6 months ago)
- Language: PHP
- Size: 17.6 KB
- Stars: 363
- Watchers: 11
- Forks: 43
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Db Encrypter Package
This package was created to encrypt and decrypt values of Eloquent model attributes.
## Donnations
If You think this package helped You, please donate. Thank You.https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SPYLWZ8Y5E4JE&source=url
## Key features
* Encrypt, decrypt values stored in database fields
* Using standard Laravel's Crypt service
* Easy configuration## Requirements
* Laravel: 6.0 and up
* PHP: 7.1 and newer#### Database schema
Encrypted values are stored as plain text so in most cases takes up more spaces then unencrypted one.
Recommendation is to alter table column to `TEXT` type.
If you want use `VARCHAR` or `CHAR` column type still you need to check if encrypted value fit.#### Note:
Do not worry if you have current data in your database not encrypted and added column to `$encryptable` - they will return as is.
On save values will be encrypted and everything will work fine.## Installation
Via Composer command line:
```bash
$ composer require betterapp/laravel-db-encrypter
```## Usage
1. Use the `betterapp\LaravelDbEncrypter\Traits\EncryptableDbAttribute` trait in any Eloquent model that you wish to use encryption
2. Define a `protected $encryptable` array containing a list of the encrypted attributes.For example:
```php
use betterapp\LaravelDbEncrypter\Traits\EncryptableDbAttribute;class Client extends Eloquent {
use EncryptableDbAttribute;
/** @var array The attributes that should be encrypted/decrypted */
protected $encryptable = [
'id_number',
'email',
];
}
```3. You can use Laravel's original $casts to cast decrypted values
### License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.