DEV Community

Automatic Laravel Data Encryption with Eloquent

Tommy Hendrawan on December 19, 2020

Few months ago i got laravel project requirement that need me to encrypt all user information that stored at database and the encrypted information...
Collapse
 
siv_casm profile image
Shivam Pandya

What about existing plain text data in database which are there before installing and configuring this package?

Collapse
 
tommyhendrawan profile image
Tommy Hendrawan

You can encrypt the old data with command below

    php artisan encryptable:encryptModel '<Your Model Path>'
Enter fullscreen mode Exit fullscreen mode

eg.

    php artisan encryptable:encryptModel 'App\User'
Enter fullscreen mode Exit fullscreen mode
Collapse
 
siv_casm profile image
Shivam Pandya

Thank you very much. :)

Thread Thread
 
codefinity profile image
Manav Misra

Nice of you to thank the author. Welcome to community! 🤓

Collapse
 
galegobr01 profile image
galegobr01

@tommyhendrawan

How does it impact query performance when the encrypted field is an index?

Thanks for response.

Collapse
 
ibrahimgamal92 profile image
ibrahim-gamal-92

Are this encryption process being done with Private key? or any one install this packages can decrypt data

Collapse
 
tommyhendrawan profile image
Tommy Hendrawan

The package use laravel key that generated when you first setup the project

Collapse
 
jayanta_mondal_40bfc314d9 profile image
Jayanta Mondal

How to use orderBy encrypted column?

Collapse
 
constantinosergiou profile image
Constantinos Sergiou

the login auth controller is not working after i have add they packages any suggestions?

Collapse
 
khushbupatel17 profile image
khushbupatel17

Is this working with auth??

Collapse
 
arebfaraz profile image
Areb Faraz

How can i set encryption key other than .env file. I dont want to use .env file to keep encryption key