Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use VARCHAR(32) for md5() values?

Tags:

php

mysql

md5

Can I use a field of length 32 and of type VARCHAR in a MySQL database for md5() values?

like image 529
Michael Avatar asked Feb 17 '13 14:02

Michael


People also ask

What is datatype of MD5 hash?

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.

What is the MD5 length?

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.

How do I find the MD5 password in MySQL?

$salt = 'Vwm'; $password = '123123'; echo md5($salt . md5($password . $salt) . $password);

What is MD5 in MySQL?

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.


1 Answers

Since md5 always produces fixed length result, better use CHAR(32)

like image 122
Marko D Avatar answered Oct 18 '22 00:10

Marko D