I've implemented vouchers module in my web project where I use it to generate redeem get etc... vouchers.
since voucher codes are considered sensitive, I've considered to encrypt them using AES-GCM.
but how can I query clear voucher code to encrypted one to check voucher validity in order to redeem later?
I've thought of these two solutions
- I am thinking to make like a MD5 for the clear code to live in the document, in order to match it with clear code queries?
- Reversed distribute, where to give the user encrypted voucher codes, and store the clear voucher codes on the DB, when a query is applied to redeem a voucher system decrypt code applied with secret key and iv and looks for a match?
Does those approaches carries less performance overhead than decrypting whole data?, is it safe to consider one of them.
Audience of threats
- system admins
- attackers
- DB data breach