filePath是文件的路径 引入 System.Text,System.IO, System.Security.Cryptography 命名空间
public static string GetMD5Vlues(string filePath
)
{
StringBuilder sb
= new StringBuilder();
filePath
= filePath
.Trim();
using (FileStream fs
= new FileStream(filePath
, FileMode
.Open
))
{
MD5 md5
= new MD5CryptoServiceProvider();
byte[] result
= md5
.ComputeHash(fs
);
for (int i
= 0; i
<result
.Length
; i
++)
{
sb
.Append(result
[i
].ToString("x2"));
}
}
return sb
.ToString();
}
转载请注明原文地址: https://lol.8miu.com/read-29153.html