C#获取文件MD5值方法

2021-03-22 18:25

阅读:548

标签:nbsp   str   md5   get   graph   service   ash   rom   security   

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 )
 {
 sb.Append(retVal[i].ToString(“x2″));
 }
 return sb.ToString();
 }
 catch (Exception ex)
 {
 throw new Exception(“GetMD5HashFromFile() fail,error:” + ex.Message);
 }
 }

C#获取文件MD5值方法

标签:nbsp   str   md5   get   graph   service   ash   rom   security   

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


评论


亲,登录后才可以留言!