0

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?

zer0uno
  • 103
  • 3
  • 1
    Don't merge multiple mostly independent questions into one. The second one is already addressed by [For common hashes, are their collision risks similar when considering only the first N bytes?](https://security.stackexchange.com/questions/259973/for-common-hashes-are-their-collision-risks-similar-when-considering-only-the-f). As for the first - this clearly depends on the hash you are using which you did not specify. But see [What are realistic rates for brute force hashing?](https://security.stackexchange.com/questions/38134/what-are-realistic-rates-for-brute-force-hashing) about speed – Steffen Ullrich Feb 07 '23 at 19:54
  • define crack? ie. are your inputs passwords? also, https://crypto.stackexchange.com/a/39644 *FGrieu'16* https://crypto.stackexchange.com/a/14939 *FGrieu'14* https://crypto.stackexchange.com/a/64675 *kelalaka'18* address the probability of a collision .. and i'm also seeing relevant discussion across the results in the search: https://crypto.stackexchange.com/search?pagesize=50&q=truncated%20hash%20probability%20of%20collision&searchOn=3 – brynk Feb 07 '23 at 20:01
  • @brynk No, my inputs are not password, but just links – zer0uno Feb 07 '23 at 20:33

1 Answers1

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.

ThoriumBR
  • 51,983
  • 13
  • 131
  • 149
  • 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 Feb 07 '23 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 Feb 07 '23 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 Feb 07 '23 at 21:19
  • If collision resistance is important, don't truncate it. – ThoriumBR Feb 07 '23 at 21:35