Searching in database when primary key is encrypted(email -> AES-256-CBC -> AbC&Xyz==) need help...
When I store Email address as primary key, how can I store that email addresses in encrypted format, because if I try to search multiple records then its looks not Possible. If record single then I can encrypt and then able to find same string in DB but what if I need to sort emails... #? (I'm using MySQL PHP JS(sometime) for my project backend)
Generally speaking, its not a good idea to use emails as primary keys, use auto increment identity columns instead. However, in your case i think you should decrypt every single email you fetch in case any sorting is needed (remeber you want to sort email addreses not encrypted information and therefore need to decrypt). Just remeber not to do it in the frontend 😃.