Encrypt Database Values in Laravel with DB Encrypter

Encrypt Database Values in Laravel with DB Encrypter

Laravel DB Encrypter is a package by Daniel Częstki that automatically encrypts and decrypts values stored in database fields. It uses Laravel’s standard Encryption via a trait:

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',
    ];
}

Note: encrypted values are longer than their plain text counterparts. The package recommends storing data as a TEXT column:

If your current data is not encrypted, the column will be returned as-is. You can check out the package on GitHub at betterapp/laravel-db-encrypter.

Filed in: News / packages

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Full-Stack Engineer
[REMOTE: USA Only] All Other Applications Will be Rejected Immediately"
Curricula
Senior Full Stack PHP Developer
Canada
Motto Design Studio
👉 Looking for Senior Back-End Laravel API Developer - Immediate (Full-time Contractor) 🎉
Remote
ApproveMe.com // The Document Signing Experience™
Senior Software Engineer
Remote or Los Angeles
Coverfly
Sr. Software Engineer
Salt Lake City, UT
Clearlink