0
$\begingroup$

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?

$\endgroup$
2
$\begingroup$

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}$

$\endgroup$
0
$\begingroup$

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}$$

$\endgroup$
0
$\begingroup$

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}.$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.