views:

91

answers:

2

What is the shortest hash that can be obtained and why? What happens if you try to achieve a shorter one, is there a fixed limit or does it depend on the length of the hashed data and why?

A: 

The shorter your hash, the more likely you are to experience a hash collision.

In practice, a cryptographically strong 32-bit hash is the shortest I would go for most purposes.

Cryptographically strong in this case means that slight changes to the input data will result in drastic changes in the hash value.

Eric J.
Cryptographically strong 32-bit hashes don't exist, the space is much too small.
starblue
Whether or not 32 bits is sufficient really depends on the purpose of the hash. Md5 worked very well for many years for a wide variety of purposes. Still, I agree that many more bits are desirable for many applications.
Eric J.
+1  A: 

The length of the hash just has to do with how many unique hashes you need there to be. You can have a one character length hash just as easily as a 100 character one, but there are too many collisions for 1 character.

It just depends on how many unique hashes you need. The formula is (number of characters in hash)^(length of hash). You could have (2)^2 or (68)^2 and have it long enough for what you need.

However, it is different for one-way hashes like md5 instead of encryption ones where you need to translate a given hash into the original string.

Aaron Harun