Possible field types:
BINARY(16) CHAR(32) BIGINT + BIGINT
How do I decide which one to use?
According to Best practices for efficiently storing md5 hashes in mysql, if the column always contains a MD5 hash and never NULL, then BINARY(16) is preferred and CHAR(32) is the next best choice.
Since, the length of MD5 is only 128 bits, solution of using variable output length increases the security and effectiveness of the MD5 algorithm. The security, integrity and effectiveness can be further enhanced by using a key to hash the plain text or data into cipher form to maintain data security and integrity.
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.
Its main purpose is to verify that a file has been unaltered. Instead of confirming that two sets of data are identical by comparing the raw data, MD5 does this by producing a checksum on both sets and then comparing the checksums to verify that they're the same.
If the column is indexed and you know what you're doing, BINARY(16)
for performance reasons.
Otherwise, CHAR(32)
is fine. Make sure the column uses the ascii charset though. (ascii_bin
for example)
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