Skip to content
This repository was archived by the owner on Apr 7, 2021. It is now read-only.

Type Error: won't decrypt float #18

Closed
ITwrx opened this issue Apr 5, 2018 · 4 comments
Closed

Type Error: won't decrypt float #18

ITwrx opened this issue Apr 5, 2018 · 4 comments
Assignees
Labels

Comments

@ITwrx
Copy link

ITwrx commented Apr 5, 2018

i have a column with existing data (a float) in it. i converted the mariadb data type from decimal to varchar. installed laravel-database-encryption, re-saved the data in my app and laravel-database-encryption was able to encrypt it. however, when i went to view the data in my app again, laravel-database-encryption wasn't able to decrypt it. The error can probably speak for itself.

Type error: Return value of App\Models\Entry::decryptedAttribute() must be of the type string or null, float returned

…/vendor/austinheap/laravel-database-encryption/src/Traits/HasEncryptedAttributes.php 173

i understand that the data needs to be stored as some type of text in the database and it is, but i need to be able to encrypt/decrypt any data type. Maybe i'm missing something? FYI, i just reinstalled elocrypt and it handles this same scenario fine.

thanks

@austinheap
Copy link
Owner

@ITwrx do you have some code I can quickly reproduce the issue with?

@austinheap austinheap self-assigned this Apr 16, 2018
@ITwrx
Copy link
Author

ITwrx commented Apr 16, 2018

sorry, i don't remember where this was in my app and i already switched back to elocrypt but it would have been using l5.5. also, to reproduce, you should be able to simply add a testing property to any model, set the column data type to varchar in mariadb. save a float in it using laravel-database-encryption and l5.5 and then try and echo it in a page. unless it was just me somehow. :)

@Segfaultd
Copy link

I have the same problem occuring except it's for an integer, not float.

@austinheap
Copy link
Owner

austinheap commented May 23, 2018

@ITwrx / @Tyldar pushed a potential fix to https://github.com/austinheap/laravel-database-encryption/tree/2aecf6b22f162531a1e2bd2f536a49c7cee89f3b. Unit tests for float/double and int included.

Let me know how it goes, going to close the issue unless additional issues get reported back.

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

No branches or pull requests

3 participants