Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to decrypt #20

Open
matze1708 opened this issue Sep 15, 2020 · 5 comments
Open

How to decrypt #20

matze1708 opened this issue Sep 15, 2020 · 5 comments

Comments

@matze1708
Copy link

Hello,

how can I decode a field again?

what do i have to set in model for casts?

Thank you :-)

@matze1708
Copy link
Author

Hi,

I have put the column APP_Token into the

protected $casts = [
        'email_verified_at' => 'datetime',
        'APP_Token' => EncryptableDbAttribute::class,

    ];

In the view I get the value decrypted.
But I want to search for a value in the controller, how can I do that?

my first attempt was

    $credentials = $request->only('RFID');
          
        $user = User::firstorfail()->where('APP_Token', $credentials)->pluck('id')->toArray();

@matze1708
Copy link
Author

Hello,
does anyone have an idea how I can search for the number?

Thanks.

@fabianmieller
Copy link

@matze1708 have you tried Crypt::decrypt($value);?

@caiowilson
Copy link

@matze1708 have you tried Crypt::decrypt($value);?

I did, doesn't work. I'll probably gonna have to either: leave the columns I want to search decrypted or paginate on the frontend and filter over there. cant paginate a collection (which would get me the decrypted values), idk, very weird. and i'm using the sabe method the trait uses.
I'm not sure what i'm missing

@caiowilson
Copy link

caiowilson commented Dec 27, 2022

@matze1708 have you tried Crypt::decrypt($value);?

I did, doesn't work. I'll probably gonna have to either: leave the columns I want to search decrypted or paginate on the frontend and filter over there. cant paginate a collection (which would get me the decrypted values), idk, very weird. and i'm using the sabe method the trait uses. I'm not sure what i'm missing

EG:
(incident_number is encrypted)
Incident::where('incident_number', Crypt::encrypt($request['search']))
doesnt return any matches.
same with like or ilike using %encrypted-value-from-search%, nothing comes back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants