Can I use a field of length 32 and of type VARCHAR in a MySQL database for md5() values?
MD5 hashes are always 128-bit, so a CHAR(32) holds the string of hex digits, or BINARY(16) holds the string of bytes after you UNHEX() the hex digits. Using NULL is independent of data type choice. MySQL can store NULL in lieu of a string, either CHAR or VARCHAR.
The hash size for the MD5 algorithm is 128 bits. The ComputeHash methods of the MD5 class return the hash as an array of 16 bytes. Note that some MD5 implementations produce a 32-character, hexadecimal-formatted hash.
$salt = 'Vwm'; $password = '123123'; echo md5($salt . md5($password . $salt) . $password);
The MySQL MD5 function is used to return an MD5 128-bit checksum representation of a string. The MD5 message-digest algorithm is a widely used hash function producing a 128-bit hash value. The value returned by the MD5 function is a binary string of 32 hexadecimal digits, or NULL if the argument was NULL.
Since md5 always produces fixed length result, better use CHAR(32)
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