compare previous ENCRYPT() call with new ENCRYPT() call mysql
- by contagious
I'm storing a string in mysql with the ENCRYPT() function. I want to fetch a row where that string is matched, but the new ENCRYPT() call gives me a different value, so they never match.
This is expected as i'm not (and can't) give it a consistent salt:
http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html#function_encrypt
If no salt argument is given, a random value is used.
This is the query i'm running that returns empty:
SELECT * FROM `table` WHERE ENCRYPT('string') = `enc_string`
I know this is possible because this is used by a 3rd party app, but I can't find their query where they do this. Is there a way to force ENCRYPT to use the previous salt, or predict it?