获取文件MD5码

时间:2018-08-27 05:33:03
【文件属性】:

文件名称:获取文件MD5码

文件大小:9KB

文件格式:EXE

更新时间:2018-08-27 05:33:03

MD5

用时没找到工具,自己写了个,函数如下: private 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); } }


网友评论