# Hash Collision Probabilities

Please give help! how can I calculate the probability of collision? I need a mathematical equation for my studying.

Assume, I am using SHA256 to hash 100-bits. Thus:

SHA256 {100} = 256-bits (hash values) I would like to know the probability of collision.

Gave an equation: $$K^2 / 2N$$

But I could not know what is $$K$$ and $$N$$? Is K is the output which is (256-bits) and $$N$$ is the input which is (100-bits)

• Umm... did you read the entire web page you linked to? It defines $k$ and $N$ very close to the top. – Ilmari Karonen Dec 8 '18 at 15:26
• $n$ is the output size of the hash function, $k$ is the randomly generated unique inputs. it is $k^2/2n$ – kelalaka Dec 8 '18 at 15:28
• well, then based on the equation: 100^2 / 2^256 right? – Al-Ani Dec 8 '18 at 15:34

$$n$$ is the output size of the given hash function. To find a collision you try randomly generated $$k$$ different inputs. When we say the output size is $$n$$, it means that the output space has $$2^n$$ elements.
$$k = \sqrt{2^n}$$ You can also see the general result from the birthday paradox.
To have birthday attack with 50% percentage you will need $$k = 2^{128} \approx 4.0 × 10^{38}$$ randomly generated differently input for a hash function with output size $$n= 256$$