Comments (10)
thanks for the docs. trying to automate it sounds fun, but i don't know if it will ever make it to the top of my list either. :)
from laravel-database-encryption.
Hey there @schonhose -- make sure you have use AustinHeap\Database\Encryption\HasEncryptedAttributes;
at the top of your user model. I haven't tried a direct migration from Elocrypt to this yet, so let me know how it goes!
from laravel-database-encryption.
Hey @austinheap -- I tried using use AustinHeap\Database\Encryption\HasEncryptedAttributes;
but I got the Trait 'AustinHeap\Database\Encryption\HasEncryptedAttributes' not found
error
I tried different combinations, but it just won't work. I even registered the service provider and the class alias in the app.php
just to make sure.
A composer update
does not update the package, so I am a bit baffled by this. Basically I am out of options.
from laravel-database-encryption.
I delved into the code, and it seems the correct way to use the trait would be: use AustinHeap\Database\Encryption\Traits\HasEncryptedAttributes;
. With this the error disappears.
However, using an eloquent query does not automatically decrypt the values. This has probably to do with the following from the readme:
By including the HasEncryptedAttributes trait, the setAttribute() and getAttributeFromArray() methods provided by Eloquent are overridden to include an additional step. This additional step simply checks whether the attribute being accessed via setter/getter is included in the $encrypted array on the model, and then encrypts or decrypts it accordingly.
The user
model in my case does not extends Eloquent, but Authenticatable
.
Anyway, I dug in a little deeper and tried to manually decrypt the value using
$user->name = $user->decryptedAttribute($user->name);
but this gives me the following error on line 171 of the trait: Type error: substr() expects parameter 2 to be integer, boolean given
.
So, I dug myself into an even bigger hole by performing the following code:
$test = str_replace("__ELOCRYPT__:", "", $user->name);
$test = \Crypt::decrypt($test);
dd($test);
This successfully decrypts my string to the original values. Hope this helps.
from laravel-database-encryption.
Any idea on solving the Trait 'App\HasEncryptedAttributes' not found
error? I am still stuck on this.
from laravel-database-encryption.
Hey @schonhose -- I haven't been able to replicate the bug on my side. I make a new Laravel 5.5 project, install with composer, and then it works. It's also passing the unit tests which have 100% code coverage.
Can you give me a file I can replicate the bug with?
from laravel-database-encryption.
Hey @austinheap, I have send you an email last week asking for more details what you would like to have from me.
from laravel-database-encryption.
same here. i just updated from 5.2->5.3->5.4->5.5 and uninstalled elocrypt and installed this package. copying the readme got me the same results as @schonhose. now i have
use AustinHeap\Database\Encryption;
use AustinHeap\Database\Encryption\Traits\HasEncryptedAttributes;
at the top of my model with
use HasEncryptedAttributes;
inside the class. The error is gone but the data is not decrypted. I notice that the existing data has the "ELOCRYPT" prefix so maybe this is the cause? Is going back to elocrypt (and whatever laravel version it supported) and decrypting the data prior to replacing elocrypt(or manually decrypting as shown above), the only route for upgrading between these two packages? i notice elocrypt had the option to set the prefix used. does this package retain this option? if so, i could theoretically use this option to hack my app back to functionality if it were documented/pointed out.
thanks
from laravel-database-encryption.
@ITwrx As you noticed, the prefixes that Elocrypt uses are not compatible with this package -- so there currently is no direct migration path from Elocrypt to laravel-database-encryption. Pull requests are welcome but for now you need to decrypt any data encrypted by Elocrypt, remove it, then install this package.
I'll add a note to the docs about this.
from laravel-database-encryption.
Migration instructions added to FAQ in README.md
via commit d1f2b14: https://github.com/austinheap/laravel-database-encryption/tree/d99bffc1c7c7130c2e22c77b851adc49a3a8d700#is-this-package-compatible-with-elocryptfive-out-of-the-box
As mentioned, pull requests are welcome to automate this process! 🎉
from laravel-database-encryption.
Related Issues (20)
- Releasedate for Laravel 5.7 support? HOT 1
- No Encryption then Create new Model instance HOT 1
- Encryption in Lumen for API HOT 2
- Composer dependencies conflict with Roave/SecurityAdvisories HOT 1
- PHP 7.3/7.4 unit test coverage not available
- firstOrCreate() only encrypts properties in first parameter--not second. HOT 1
- Need help with `DB_ENCRYPTION_VERSIONING=false` in .env file HOT 3
- New Version of paragonie/random_compat HOT 2
- Class 'AustinHeap\Database\Encryption\Tests\DatabaseTestCase' not found
- Laravel 5.8 support HOT 13
- Cannot decrypt model attribute with no package header! Error HOT 2
- Migrating Installs HOT 1
- Laravel 6 Support HOT 3
- Dependency version conflict HOT 1
- Please add support for Laravel 6 HOT 9
- Is there a way to encrypt old-unencrypted data? HOT 1
- Showing encrypted data HOT 2
- Decryption not working if APP_KEY is changed HOT 3
- Standalone version
- Not every record is encrypted HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-database-encryption.