I am trying to return an MD5 encoded string of a value from my database, but it just returns a blank result (not null, just blank). I have tried just running this query and get the same result:
SELECT MD5('test');
I have tried restarting the MySQL server, MySQL Workbench, etc. But get the same result. If I try running the same command on a different database/server, it returns the hash string just fine.
What am I doing wrong? Is there a setting I disabled on accident?
The md5sum of "nothing" (a zero-length stream of characters) is d41d8cd98f00b204e9800998ecf8427e, which you're seeing in your first two examples.
The value of function MD5(col1) will be NULL if the value of col1 is NULL. However, if MD5 is used along with other NON NULL values, it will ignore the NULL value input and will return hash value of NON NULL input arguments.
What is MD5? MD5 (message-digest algorithm) is a cryptographic protocol used for authenticating messages as well as content verification and digital signatures. MD5 is based on a hash function that verifies that a file you sent matches the file received by the person you sent it to.
Prior to MySQL v5.5.3, MD5()
returned a binary string.
By default, MySQL Workbench does not display binary strings (to avoid accidental misinterpretation); however it is possible to display binary string values in output grids: View > Edit > Preferences > SQL Editor > Treat BINARY/VARBINARY
as nonbinary character string.
Alternatively, either upgrade your MySQL server or transcode the result to a non-binary character set:
SELECT CONVERT(MD5('test') USING utf8)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With