Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do hashes collide?

Tags:

algorithm

hash

I understand that according to pigeonhole principle, if number of items is greater than number of containers, then at least one container will have more than one item. Does it matter which container will it be? How does this apply to MD5, SHA1, SHA2 hashes?

like image 550
user963241 Avatar asked Feb 28 '10 00:02

user963241


People also ask

How often do hash collisions occur?

As a rule of thumb, a hash function with range of size N can hash on the order of √N values before running into collisions. This means that with a 64-bit hash function, there's about a 40% chance of collisions when hashing 232 or about 4 billion items.

Has there ever been a hash collision?

Hash CollisionsOver the past few years there have been some publicized attacks against the MD5 algorithm in which researchers were able to generate two different files that generated the same MD5 hash value.


1 Answers

No it doesn't matter which container it is, and in fact this is not that important to cryptographic hashes; much more important is the birthday paradox, which says that you only need to hash sqrt(numberNeededByPigeonHolePrincipal) values, on average, before finding a collision.

Thus, the hash needs to be large enough that the square-root of the search space is too large to brute-force. The square-root-of-search-space for SHA1 is 280, and as of March 2012, no two values have ever been found with the same SHA1-hash (though I predict that will happen within the next year or two..); same with SHA2, a family of hashes which all have an even larger search-space. MD5 has been broken for a while though.

like image 178
BlueRaja - Danny Pflughoeft Avatar answered Nov 15 '22 22:11

BlueRaja - Danny Pflughoeft