A property of a hash function is that the hash output is of fixed length (ex. 256). The number of possible hashes is 2^256, and the number of possible strings to be hashed is infinite. So, (obviously) there are strings (also infinite ?) with the same hash. My question is, what is the probability of two different strings resulting on the same hash ? Is it just 1/2^256 meaning that the hash function is uniform ? or it can be another number ?
Asked
Active
Viewed 551 times
0
-
I'm voting to close this question as off-topic because it's not related to programming. Maybe better suited for crypto.stackexchange.com. – Topaco Mar 27 '20 at 08:22
-
@Topaco It's a combination of crypto and probabilities. That's why I asked it here. – Mar 27 '20 at 12:00
-
3The probably of two specific strings having the same hash code is 1/(2^256). The probability of having a hash collision depends on the number of strings hashed. Given a good hashing function, it's the [Birthday Problem](https://en.wikipedia.org/wiki/Birthday_problem). If you don't have a good hashing function, then the collision probability is higher. – Jim Mischel Mar 27 '20 at 17:00