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

Hashed, searchable columns #4

Closed
brycedarling opened this issue Aug 19, 2019 · 6 comments
Closed

Hashed, searchable columns #4

brycedarling opened this issue Aug 19, 2019 · 6 comments

Comments

@brycedarling
Copy link

I cannot find any documentation on how to make make hashed, searchable columns to go along with my encrypted column. Any help would be appreciated, thanks for the sweet lib!

@brycedarling
Copy link
Author

Nevermind, found it in the docs after thinking to search for "hash" ;)

https://hexdocs.pm/cloak_ecto/Cloak.Ecto.PBKDF2.html#module-usage

Thank you!

@sveredyuk
Copy link

Hi, I have maybe a stupid question but is it possible to search with like or like by hashed fields?

@brycedarling
Copy link
Author

@sveredyuk as far as I know, the hash is only useful for an exact equality lookup. a string like "this is some text" will be hashed to a value like DV5hk0ryjAsvSp3uFhhLog1tLp3/aA7/ttGFAq1yg9k= so it wouldn't be very useful to do a LIKE query on. when searching the table, the value you are looking for also gets hashed so that it can try find a row with that exact same matching hash.

@acrolink
Copy link

@sveredyuk as far as I know, the hash is only useful for an exact equality lookup. a string like "this is some text" will be hashed to a value like DV5hk0ryjAsvSp3uFhhLog1tLp3/aA7/ttGFAq1yg9k= so it wouldn't be very useful to do a LIKE query on. when searching the table, the value you are looking for also gets hashed so that it can try find a row with that exact same matching hash.

I have the same suspicion. Correct, true ? only exact full string match would work?

@sveredyuk
Copy link

Definitely. Using LIKE for hashed values will give you nothing. Or exact match or just use another soution

@jaimeiniesta
Copy link

I also came here looking for a way to search with LIKE in a hashed column, now I understand this is not possible. Maybe the documentation could say something like "findable" instead of "searchable" to imply that hashes allow you to find matching records, like exact emails or tokens, but not inside the content with LIKE.

A possible solution if there are not many records is to load the content in memory so that it's decrypted and then search with Elixir.

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

4 participants