我正在尝试实现一种检测重复文件的方法。我有一个MD5哈希方法(让我们忽略MD5已经被破解的事实),如下:
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")));
}
我是否可以直接用hashBytes
创建一个Guid
,而不是将其转换为string
?
Guid hashGuid = new Guid(hashBytes);
这个值是否仍然有效,或者我会失去唯一性?