简体   繁体   中英

Postgres : Like search where data is encrypted at column level

I have a Postgresql db of version 9.4.1 to be very specific. Values of certain columns of some table are encrypted, now i have scenario where i need to use such encrypted columns in where condition with like pattern. To encrypt data under columns i am used AES encryption scheme and doing encryption() and decryption() on java side only, so now my database is not aware of what plaintext values are stored.

Above logic works perfectly for exact search but LIKE search is failing here

For example: Let's say data under customername column of customer table is encrypted and i want to perform like search on customername as follows.

select customer_id from customer where customername like '%'+encryption(ABC)+'%'

Post evaluating multiple suggested options, i finally concluded issue using Pgcrypto module of postgres. pgcrypto allows like search too, only drawback here is length of column needs to increased.

Details of Pgcrypto module are available here.

https://www.postgresql.org/docs/9.0/pgcrypto.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM