1

From what I've researched, SHA's hex encoded string contains the characters [a-fA-F0-9]. If we represent it in Base64, it can contain [a-zA-Z0-9+/].

So the number of possible hash permutations are 22^64 and 59^64 respectively.

My question is, while we have infinite permutations for the input text, if the output hash is finite, then aren't all SHA algorithms meant to collide at some point?

I'm self taught. So please bear if this is a basic thing in cryptography.

1 Answers1

2

My question is, while we have infinite permutations for the input text, if the output hash is finite, then aren't all SHA algorithms meant to collide at some point?

Due to the pigeonhole principle, all hash functions will collide at some point. Since there are more inputs than outputs, the existence of collisions is unavoidable.

The job of a cryptographic hash function is to make finding collisions cost so much that it will never happen, and to make finding preimages prohibitively expensive as well.

Ella Rose
  • 19,603
  • 6
  • 53
  • 101
  • Nitpicking: It‘s assumed that every hash value will collide, but you just can‘t be sure about that. There are certainly some hashes with collisions, but maybe there is a unknown flaw in the algorithm that would prevent the outcome of a certain hash value (or the possibility for infinite hashes for every possible hash-value). To reference the pigeonhole principle: There are 10 pigeons and 9 holes. It‘s certain that at least one hole has two or more pigeons. But they could also be one hole that is empty and one with three pigeons. – AleksanderCH Aug 11 '18 at 13:47