If I don’t want to store user emails in plain text in the database, but need them for running look-ups, is there a way to both encrypt (two-way so the content can be retrieved) and easily look up the value?
EDIT Would storing two columns, one encrypted for display and one hashed for lookup work?
MySQL has
aes_encrypt()andaes_decrypt()for this sort of thing, but then you’re still passing the encryption key in-the-clear, which means you might as well just be passing around the email addresses in-the-clear.The basic method would be something like:
but again, you’d not be gaining any security since you’re sending the key each time.