0

is it possible that hash function produces the same hash value for two different inputs ? I am not mistaken I have read that hash function is one way encryption, so we cannot go back to the input using the result, and read that even if we change a bit of the ducoment that is directed to be hadhed will give another hash value, so how does collusion happen? and how is it possible for a hash function to produce the same value for two different inputs?

zahreddine
  • 65
  • 5
  • 1
    Hash collisions are [inevitable](https://en.wikipedia.org/wiki/Hash_collision). In any case, I’m voting to close this question because it's not about programming. – r3mainer Feb 24 '22 at 10:35
  • [What Exactly is Hash Collision](https://stackoverflow.com/questions/45795637/what-exactly-is-hash-collision) – Dalija Prasnikar Feb 24 '22 at 10:59

1 Answers1

1

Yes. The range of any hash function is limited by the number of bits. For example, if we were to use a hash function outputting 8 bits, then we only have 256 possible outputs; so if we have more than 256 possible inputs then we are guaranteed to have a collision.

If we use a hash function with a larger range then it becomes much less likely to have a collision; but cannot make it impossible because our inputs are unlimited.

The existence of collisions is part of the reason why these functions are one way: a given output could have been generated from an unlimited number of different inputs.

We should also use a good cryptographic hash function to help avoid collisions from similar input.

You may want to look at the "SHAttered" example of 2 different PDF files that have the same SHA1 hash.