I'm running this sample code I found while googling:
But, to my surprise, MD5 is returning plain digits, instead of hexadecimal digits.
CONV(MD5(RAND()), 10, 16) seems to solve my problem, but the MySQL documentation states that the MD5 function should return a string already in hexadecimal.
Am I doing something wrong?
EDIT2: This problem only appears to exist with phpMyAdmin, not the command-line version of MySQL.
EDIT: My MySQL version:
mysql --version mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (x86_64) using readline 6.1
An example MD5 value:
Also, CONV returns a very VERY short string, like:
This string is often single-digit and the longest I got until now was 5 digits.
Nevermind, I figured it out.
Somehow, phpMyAdmin is reading the result as binary. There seems to be an option "Show binary contents as HEX" that's checked by default.
It appears that this "show as hex" option is causing the problems. Unchecking it seems to solve it.
The MySQL documentation does suggest that the result should be a string or NULL no matter what. At a guess, could this be happening because the argument to MD5() is a number? What happens if you use
SELECT MD5(CONCAT(RAND(), ''))?