I want to compare an string which is in clear text in the database with an string that is hashed with MD5(). I’ve tried to do something like this:
SELECT member_email, is_validated FROM members
WHERE CONVERT(VARCHAR(32), HASHBYTES('MD5', 'member_email'), 2) = '".$_GET['vy']."'
AND is_validated = '0'
But I’m getting You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARCHAR(32), HASHBYTES('MD5', 'member_email'), 2) = '' AND is_valida' at line 2. If I remove ‘ in 'member_email' so it’s HASHBYTES('MD5', member_email) I’ll getting the same error message. What’s wrong? Do I have to put the MD5 hash in the database to compare it with the same MD5 hash in $_GET['vy']?
Thanks in advance!
Does MySQL have
HASHBYTES()? http://dev.mysql.com/doc/refman/5.6/en/encryption-functions.htmlHave you tried: