I am looking to generate unique 16-byte / 128-bit hased IDs (GUIDs) that does not need to be cryptographically secure. For example imagine that the hash is the 128-bit MD5("some user generated strings");
I would have preferred to use a SHA algorithm, but SHA doesn't come in a 128-bit variant AFAIK. The older MD5 generates a 128-bit hash which is exactly what I need.
But since the SHA algorithm is presumably newer / better than the MD5 algorithm, what would yield the best result:
- Using MD5?
- Or using SHA-256 and XOR'ing the two 16-byte halves together to get a 128-bit hash?
- Or simply using the first 128 bits of SHA-1 or SHA-256 (this is answered in other Stackoverflow questions e.g. here Using N first bits of a hash function to have an N-bit hash)
Would 3 e.g. be better than 2? Or are they equally good?
I have no clue about the inner workings of SHA, so my question might be totally off, please help enlighten me. Thanks!