首页 > Windows开发 > 详细

C#获取文件MD5值方法

时间:2018-08-15 22:34:22      阅读:184      评论:0      收藏:0      [点我收藏+]

https://www.cnblogs.com/Ruiky/archive/2012/04/16/2451663.html

 

 

private 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 (Exception ex)
 {
 throw new Exception(“GetMD5HashFromFile() fail,error:” + ex.Message);
 }
 }

C#获取文件MD5值方法

原文:https://www.cnblogs.com/LuoEast/p/9484136.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!