0

I am using spring jpa with mysql database to encrypt the PII data by using the @convert annotation. The encryption and decryption is working properly. The problem is with search functionality. When i am searching with full text, search is working However when i try to search like below it is not working.

select email_id from customer where email_id like '%'+encryption(sher)+'%'.

can anyone suggest any help on this ? Or if there is any different approach for db column encryption/decryption which supports pattern search for encrypted data ?

Thank you!

  • The suggestion mentioned above will add performance overhead if we have lakhs of records. can you please suggest different approach to encrypt the fields and which should support 'contains/pattern' search ? – sherali inamdar Jul 15 '22 at 06:42
  • That is not possible as far as I can tell. The issue is that the encryption is happening within your application and not the database. In the database you have a record, lets say `hello world`, which is encrypted to `dlr0w 0ll3h`. Now how would you want to search for a partial match? Lets say you do something `like '%world%'`, that would yield no result. And depending on the encryption method, `world` alone could never become `dlr0w`, again making a match impossible – XtremeBaumer Jul 15 '22 at 07:06

0 Answers0