Polyscope - The agent-first dev environment for Laravel

Laravel Db Encrypter

betterapp/laravel-db-encrypter image

Laravel Db Encrypter stats

Downloads
324.3K
Stars
364
Open Issues
11
Forks
42

View on GitHub →

Provides database model attribute encryption/decryption

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:

$ 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:

 
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',
];
}
  1. You can use Laravel's original $casts to cast decrypted values

License

The MIT License (MIT). Please see License File for more information.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Betterapp Laravel Db Encrypter Related Articles

Encrypt Database Values in Laravel with DB Encrypter image

Encrypt Database Values in Laravel with DB Encrypter

Read article
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Typesense Search logo

Typesense Search

Typesense is an open source, blazing-fast search engine, optimized for helping you build delightful search experiences for your sites and apps. Natively integrated with Laravel Scout.

Typesense Search
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Celebian logo

Celebian

Celebian is a social media marketing agency specializing in helping their clients go viral on TikTok. Whether you're looking to reach a bigger audience or gain more Tiktok followers, likes, and views, they've got you covered.

Celebian
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell