Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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

share|improve this answer

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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