kid526940065

//获取文件MD5算法
private static string GetMD5FromFile(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 (Exception ex)
{
throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message);
}
}

相关文章:

  • 2021-10-17
  • 2021-05-30
  • 2022-12-23
  • 2021-10-17
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-17
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案