in reply to How safe is truncating an MD5 digest string?

Over and above the other suggestions given so far, I would add that if you were worried about reducing the digest's randomness, then take the 16-byte binary value of the digest, split it into two 8-byte values, xor them together, and then produce a base64 digest from that.

You might also consider just lopping off four bytes and and xoring them into the remaining bytes (or not). Either way, that would give you 1/2**96 chance of collision, something like 79 228 162 514 264 337 593 543 950 336, which would appear to be a reasonable margin of safety...

--
g r i n d e r
  • Comment on Re: How safe is truncating an MD5 digest string?