1
$\begingroup$

What is the chance for collision or resistance of a hash made out of 5 chars randomly picked from this sets a-z A-Z and 0-9 (62 chars total).

Also, what is total amount of combinations without collision that I can get, AFAIK :

$62^5 = 916.132.832$

Thank you.

$\endgroup$
1
1
$\begingroup$

There are indeed $62^5 = 916\,132\,832$ possible hashes in that syntax. If they are uniformly distributed, then the standard birthday paradox applies to the probability of a collision in $n$ independent choices of $k$ possible hashes. For $n < \sqrt{k}/4$, the probability of collision is between $(n - 1)^2/(4k)$ and $n^2/k$. For example, among 10 000 hashes, the probability of a collision is at least $$\frac{9\,999^2}{4\cdot916\,132\,832} > 2.7\%,$$ and at most $$\frac{10\,000^2}{916\,132\,832} < 11\%.$$

Of course, if these are hashes from a fixed public hash function like SHAKE128-30 (add two more characters to your alphabet like the base64 + and - to make the numbers work out), it is easy for an adversary to spend the energy to compute a few tens of thousands of hashes offline without interacting with you in order to find a collision with high probability. The lower bound on the collision probability gives a guarantee on the adversary's chance of success after a certain amount of work.

So with numbers as small as this, not much can be said about fixed public hash functions. On the other hand, this analysis remains relevant for a secret hash function, a pseudorandom function family (PRF), like SipHash or KMAC128 or keyed BLAKE2 under a secret key not known to the adversary.

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