Chance that first 6 characters of a SHA-1 hash matching another SHA-1 hash?

3.1k Views Asked by At

Just what the question says -- what is the chance that the first six characters of a SHA-1 hash will match the first six characters of any given SHA-1 hash?

3

There are 3 best solutions below

0
On BEST ANSWER

SHA-1 produces a 120 bit value, no characters. However, such hashes are often conveyed using a string of fourty hex digits. The probability of six identical hex digits (assuming with suitable justification uniform distribution) is $\frac1{16^6}$

0
On

A SHA-1 hash is supposed to be almost random, so I'd say $$P = \frac{1}{256^6} \approx 3.55 \cdot 10^{-15}$$ Assuming you mean "byte" by character. However, this might only be approximate, as the algorithm is quite complex. If you mean HEX-Digit representation, it would be a base of $16$ i.E. $$P = \frac{1}{16^6} \approx 5.96 \cdot 10^{-8}$$

0
On

Assuming that they are pseudo-uniform and i.i.d. (which I believe is the goal), then there are $16^6$ beginnings for a hash, each equally likely. The probability of collision (that two hashes begin with the same 6 characters) is then $$\frac{1}{16^6} = 16^{-6} = 2^{-24}.$$