Questions tagged [hash-collision]

a situation that occurs when two distinct pieces of data have the same hash value, checksum, fingerprint, or cryptographic digest.

See also the wiki tag.

212 questions
563
votes
6 answers

How would Git handle a SHA-1 collision on a blob?

This probably never happened in the real-world yet, and may never happen, but let's consider this: say you have a git repository, make a commit, and get very very unlucky: one of the blobs ends up having the same SHA-1 as another that is already in…
Gnurou
  • 7,502
  • 3
  • 20
  • 32
195
votes
9 answers

Hash collision in git

What would actually happen if I had a hash collision while using git? E.g. I manage to commit two files with the same sha1 checksum, would git notice it or corrupt one of the files? Could git be improved to live with that, or would I have to change…
Sec
  • 6,546
  • 5
  • 29
  • 57
119
votes
3 answers

hash function in Python 3.3 returns different results between sessions

I've implemented a BloomFilter in python 3.3, and got different results every session. Drilling down this weird behavior got me to the internal hash() function - it returns different hash values for the same string every session. Example: >>>…
redlus
  • 1,431
  • 2
  • 10
  • 16
99
votes
11 answers

Can two different strings generate the same MD5 hash code?

For each of our binary assets we generate a MD5 hash. This is used to check whether a certain binary asset is already in our application. But is it possible that two different binary assets generate the same MD5 hash. So is it possible that two…
Lieven Cardoen
  • 23,220
  • 47
  • 141
  • 228
59
votes
3 answers

What's the shortest pair of strings that causes an MD5 collision?

Up to what string length is it possible to use MD5 as a hash without having to worry about the possibility of a collision? This would presumably be calculated by generating an MD5 hash for every possible string in a particular character set, in…
Alf Eaton
  • 4,344
  • 3
  • 35
  • 43
50
votes
5 answers

What are the chances that two messages have the same MD5 digest and the same SHA1 digest?

Given two different messages, A and B (maybe 20-80 characters of text, if size matters at all), what is the probability that the MD5 digest of A is the same as the MD5 digest of B and the SHA1 digest of A is the same as the SHA1 digest of B? That…
John Siracusa
  • 14,231
  • 6
  • 39
  • 53
38
votes
2 answers

What is the clash rate for md5?

What's the probability for the clash for the md5 algorithm? I believe it is extremely low.
Adam Lee
  • 21,598
  • 43
  • 138
  • 208
25
votes
4 answers

Examples of Hash-Collisions?

For demonstration-purposes, what are a couple examples of strings that collide when hashed? MD5 is a relatively standard hashing-option, so this will be sufficient.
Sampson
  • 251,934
  • 70
  • 517
  • 549
23
votes
6 answers

Probability of getting a duplicate value when calling GetHashCode() on strings

I want to know the probability of getting duplicate values when calling the GetHashCode() method on string instances. For instance, according to this blog post, blair and brainlessness have the same hashcode (1758039503) on an x86 machine.
Diego
  • 1,501
  • 14
  • 27
21
votes
4 answers

What Exactly is Hash Collision

Hash Collision or Hashing Collision in HashMap is not a new topic and I've come across several blogs and discussion boards explaining how to produce Hash Collision or how to avoid it in an ambiguous and detailed way. I recently came across this…
sribasu
  • 627
  • 2
  • 5
  • 23
19
votes
1 answer

Is this an appropriate use of python's built-in hash function?

I need to compare large chunks of data for equality, and I need to compare many pairs per second, fast. Each object is guaranteed to be the same length, it is possible and likely that there may only be slight differences located at unknown…
wim
  • 266,989
  • 79
  • 484
  • 630
16
votes
5 answers

Unexpected collision with std::hash

I know hashing infinite number of string into 32b int must generate collision, but I expect from hashing function some nice distribution. Isn't it weird that these 2 strings have the same hash? size_t hash0 =…
relaxxx
  • 6,646
  • 7
  • 34
  • 63
16
votes
4 answers

How to handle hash collisions for Dictionaries in Swift

TLDR My custom structure implements the Hashable Protocol. However, when hash collisions occur while inserting keys in a Dictionary, they are not automatically handled. How do I overcome this problem? Background I had previously asked this question …
Suragch
  • 364,799
  • 232
  • 1,155
  • 1,198
16
votes
3 answers

How well does .NET dictionary resolve collisions?

I have a problem with a custom object that needs to be keyed for a table. I need to generate a unique numeric key. I'm having collision problems and I'm wondering if I can leverage a dictionary to help me. Assume I have an object like this: class…
Tesserex
  • 16,418
  • 5
  • 61
  • 101
14
votes
3 answers

How does Dictionary use the Equatable protocol in Swift?

In order to solve this question, I have been playing around with a custom struct that implements the Hashable Protocol. I'm trying to see how many times the equivalency operator overload (==) gets called depending on if there is a hash collision or…
Suragch
  • 364,799
  • 232
  • 1,155
  • 1,198
1
2 3
14 15