I am trying to implement a method for detecting duplicate files. I have an MD5 hashing method (let's ignore the fact that MD5 is broken) as below:
using(MD5 hasher = MD5.Create())
using(FileStream fs = File.OpenRead("SomeFile"))
{
byte[] hashBytes = hasher.ComputeHash(fs);
string hashString = string.Join(string.Empty, hashBytes.Select(x => x.ToString("X2")));
}
Instead of creating a string
out of the hashBytes
can I simply create a Guid
out of it like so?
Guid hashGuid = new Guid(hashBytes);
Would it still be valid or will I lose uniqueness?