Probability of 64bit Hash Code Collisions

后端 未结 4 982
天涯浪人
天涯浪人 2021-02-04 07:30

The book Numerical Recipes offers a method to calculate 64bit hash codes in order to reduce the number of collisions.

The algorithm is shown at http://www.javamex.com/tu

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 08:06

    Is there a formula to estimate the probability of collisions taking into account the so-called Birthday Paradox?

    See: Birthday attack.

    Assuming the distribution of hashes is uniform, the probability of a collision for n keys is approximately n2/265.

    Is it safe to assume that a collision of a reasonable number of keys (say, less than 10,000 keys) is so improbable so that if 2 hash codes are different we can say that the keys are different without any further checking?

    It's only safe when you use a cryptographic hash function. Even if you can tolerate a mistake every 3*1011 times, you may have to consider the possibility that the input is specifically built to create a hash collision, as an attack on your program.

提交回复
热议问题