I have a follow-up question to another question, Encrypt and decrypt a string, posted by someone else.
I tried out the code posted by Brett, the one that has 190 up votes (and counting). What I noticed is that it is possible that with the same text, salt, and shared secret to get different encrypted results. The different encrypted results do, however, decrypt to the expected value.
My problem is that means that if I encrypt various database fields, then without the consistency, I cannot encrypt values given by the user, and use that in a select statement in a database. The following code would thus fail:
SELECT `Id` FROM mySqlTable WHERE `userid` = 'encryptedentry1' AND `userpw` = 'encryptedentry2';
How does one do queries on a database, where the columns are encrypted?