DataBase Retreival and compare a value by iterating the list retreived from database

0
Hi, i have an attribute called Number(kind of password),  this field is stored in database as encrypted value. My requirement is: User fills data and clicks on save button. In save button, i have logic to decrypt this field and check this field value is exists in database already(based on this i will show Validation Message). For this, i have retrieved the list from database and did iteration. While iterating, for each object i decrypted the field and compared this with the field coming from form. This causes perfomanace issue if we have lakhs of records in database. Is there any way, we can get decrypted list of values from database, so that i can use Filter to check instead iterating it?
asked
1 answers
0

Is it possible working the other way around?

Generally encryption should be much faster than decryption. So you could take your unencrypted value, encrypt it, and compare that to the DB value.

Hope this helps

answered