简体   繁体   中英

Field Level Encryption of Data jpa

I am able to achieve field level encryption of data using converter. But it is applicable for entities only. Not applicable in JPA repository. For example, I have a requirement to search with that sensitive data using JPARepository like findBySensitiveColumn. Apparently that is not encrypted, so it cannot search in the database with the plain text. If i try to use the same encryption used in side the converter, it gives me different value, ending up on mismatch with database. I know this could be the repeated question. But i tried encryption listener too. But it doesnt work. pls help

One possible solution is to hash the part of the data field you want to search on before encrypting, ie hash all or part of the plaintext. Then store the hash in a new column with a link to the encrypted data. When you want to search the encrypted data, hash your search, find the matching hash and follow the link to retrieve the appropriate data to decrypt.

The big problem is partial searching and fuzzy matches, which will not work. Hashes are very sensitive to data changes so you will have to match the search key exactly. "Chris Smith" will fail when it should have been "Chris J. Smith". You will lose a lot of flexibility in your searching.

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