A follow-up to Is there a greater chance to collide when comparing GUIDs created differently?.
I have something like this:
using( MD5 md5 = MD5.Create() ) {
var hash = md5.ComputeHash( foo );
var hashguid = new Guid( hash );
}
This guarantees the same foo
will cause a GUID collision, and allows filtering of duplicates of foo
.
Is there any concerns that hashguid
has a greater chance to collide with GUIDs generated with Guid.NewGuid()
(vs. two GUIDs generated with Guid.NewGuid()
)?
Cryptographically strong hash algorithms do not increase the chance of collision significantly when compared to the chance of collision for the hash input. This is safe.
There is no practical reduction of collision risk by structuring a guid in a certain way. The collision chance of randomly generated guids is so low that even the Mars Rover can rely on that not to happen.
MD5 is a broken algorithm and I would not call it cryptographically strong. I don't understand why people still use MD5. Isn't this common knowledge 10 years after the breaking?! Consider using SHA256 and truncating the output to 128 bits.