public static string GetMD5HashFromFile(string filename)
{
try
{
FileStream file = new FileStream(filename,FileMode.Open);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString();
}
catch (System.Exception ex)
{
Debug.Log("错误信息:"+ex);
return null;
}
}
C# 获取文件md5码值
猜你喜欢
转载自blog.csdn.net/weixin_37744986/article/details/80534445
今日推荐
周排行