Skip to content

Instantly share code, notes, and snippets.

View ndamclean's full-sized avatar

Nathan McLean ndamclean

  • Kinsol Research
View GitHub Profile
@ndamclean
ndamclean / birthday.py
Created April 19, 2024 00:28
Generalizable form of the "birthday problem" for getting the probability of hash collisions
"""
Generalizable form of the "birthday problem"
https://en.wikipedia.org/wiki/Birthday_problem
This can be used to get an idea of the viability of hash function.
e.g. if a hash function results in a hash that can be represented by 8 hex
digits (16^8 = 4,294,967,296 possible hash values) and you expect to be hashing
100,000 values, you can use "100,000" as the "n" value and "4,294,967,296"
as the "m" value to get the probability of hash collisions: