Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size of MD5 hash generated

I would be using MD5 hashing to store encrypted passwords. Password can be 6 to 40 characters long. What is the database column size required for storing the encrypted password. Also, if 40 characters hash size is very large, then how much hash size would a 20 character password take?

I am using FormsAuthentication.HashPasswordForStoringInConfigFile(stringToEncrypt, "MD5"); to generate hash for storing in Database.

like image 593
Jatin Avatar asked Aug 09 '11 08:08

Jatin


People also ask

What is the size of hash produce by MD5?

MD5 creates a 128-bit hash value based on any input length.

Is MD5 fixed size?

MD5 processes a variable-length message into a fixed-length output of 128 bits. The input message is broken up into chunks of 512-bit blocks (sixteen 32-bit words); the message is padded so that its length is divisible by 512.

What is the size of buffer in MD5?

The size of each buffer is 32 bits. 4. Process Each 512-bit Block: This is the most important step of the MD5 algorithm.

What is the maximum length for MD5 input output?

The hash is always 128 bits. If you encode it as a hexdecimal string you can encode 4 bits per character, giving 32 characters.


2 Answers

A hash algorithm always maps an arbitrary sized message to a fixed-length representation. In other words, you can hash an empty string or many gigabytes of information. The hash size is always fixed.

In your case the hash size is 128 bits. When converted to an ASCII string it would be a 32 character string that contains only hexadecimal digits.

like image 164
Mehran Avatar answered Oct 12 '22 22:10

Mehran


http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5.aspx

The hash size for the MD5 algorithm is 128 bits, regardless of the length of the string being hashed.

Consider using a newer hashing functions like SHA 256.

like image 24
Jakub Konecki Avatar answered Oct 13 '22 00:10

Jakub Konecki