Coder Social home page Coder Social logo

Comments (10)

ITwrx avatar ITwrx commented on August 16, 2024 1

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.

austinheap avatar austinheap commented on August 16, 2024

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.

schonhose avatar schonhose commented on August 16, 2024

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.

schonhose avatar schonhose commented on August 16, 2024

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.

schonhose avatar schonhose commented on August 16, 2024

Any idea on solving the Trait 'App\HasEncryptedAttributes' not found error? I am still stuck on this.

from laravel-database-encryption.

austinheap avatar austinheap commented on August 16, 2024

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.

schonhose avatar schonhose commented on August 16, 2024

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.

ITwrx avatar ITwrx commented on August 16, 2024

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.

austinheap avatar austinheap commented on August 16, 2024

@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.

austinheap avatar austinheap commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.