void GetMD5(string path)
{
if (!File.Exists(path))
{
Debug.Log("不存在该文件");
return;
}
FileStream stream = File.OpenRead(path);
MD5 md5 = new MD5CryptoServiceProvider();
byte[] values = md5.ComputeHash(stream);
stream.Close();
string md5value = string.Empty;
foreach (var item in values)
{
// md5value += Convert.ToString(item, 16);
md5value += item.ToString();
//Debug.Log("item=="+item);
}
Debug.Log("md5值为:" + md5value);
}
其中,foreach循环里面最终的值是10进制的MD5码,如果需要转换成2进制或其他进制的话,使用Convert.ToString(item,进制数)即可