# SHA's finite character set and collision

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.

• Possible duplicate of For any hash value, is there an infinite number of inputs that hash to it? – AleksanderRas Aug 10 '18 at 12:40
• It is also worth noting that SHA output is a string of bits, and we encode in hex ([0-9a-f] where case for a-f doesn't matter, so 16^64 = 2^256) or base-64 (encoding 256 bits in 42.7 -> 43 characters, so 64^43 = 2^258, so we typically ignore two bits) for convenience when working with it as humans. – Eugene Styer Aug 10 '18 at 13:27
• Oh alright @EugeneStyer I didn't know that. But that doesn't answer my doubt. I went through what AleksanderRassasse has pointed out. But it was difficult for me to comprehend. I'll go through that answer once again. – Subramanian Sridharan Aug 10 '18 at 13:48