laravel-aescrypt icon indicating copy to clipboard operation
laravel-aescrypt copied to clipboard

How to search with %something% on a WHERE clause?

Open sketchminds opened this issue 6 years ago • 2 comments

Hi,

Does your package support searching on encrypted values? If yes, how do you implement it?

Thanks.

sketchminds avatar Jul 24 '18 10:07 sketchminds

Hi,

Any updates?

Thanks.

sketchminds avatar Jan 21 '19 09:01 sketchminds

You should be able to do it with a raw query, like this:

SELECT *, AES_DECRYPT(REPLACE(first_name,'__AESCRYPT__:',''), <aes-key>) AS first_name_aes
FROM people
HAVING first_name_aes LIKE '%something%'

But you need to use a HAVING clause, not a WHERE clause.

infostreams avatar Jun 21 '19 07:06 infostreams