I would like to map strings of arbitrary length to hashes of 10 character length.

The length of the alphabet is of 64 characters (0-9, A-Z, a-z, _, -).

Obviously 2 same strings must produce the same hash.

I have the following doubts:

  1. With 64 characters and a hash length of 10 characters I have a number of combination of 64^10 = 1,15*10^18. How long would it require for a modern computer to crack it?

  2. To guarantee that 2 same strings produce the same hash I was thinking to apply a SHA function to the string and then truncate the output to 60 bits (64 = 2^6). In this case, which SHA function should I use and why? And what's the collision probability in such case?


1 Answer 1

  1. Not possible to calculate unless we know the difficulty of the hash.

  2. A hash function is deterministic, so the same string will always return the same output. For outputting 60 bits, you could use any hash function that have more than 60 bits on the output.

  • 1. I would use a SHA function, which one? Depends on point 2. 2. Is there any really difference between MD5, SHA256, SHA512 given that each of than has un output longer than 60 bits?
    – zer0uno
    Commented Feb 7, 2023 at 20:13
  • It depends on the purpose of the hash. If you want a fast hash, use MD5. If you want collision resistance, use SHA. As you are truncating the result, SHA-256 is enough.
    – ThoriumBR
    Commented Feb 7, 2023 at 20:51
  • Is there any degradation in the collision resistance if I truncate SHA256 to 60bits? Is there any formula to calculate the collision resistenze?
    – zer0uno
    Commented Feb 7, 2023 at 21:19
  • If collision resistance is important, don't truncate it.
    – ThoriumBR
    Commented Feb 7, 2023 at 21:35

Not the answer you're looking for? Browse other questions tagged .