2023年12月8日发(作者:)

c#MD5校验文件

代码

private string GetMd5Hash(string pathName)

{

string strResult = "";

string strHashData = "";

byte[] arrbytHashValue;

ream oFileStream = null;

5CryptoServiceProvider oMD5Hasher =

new 5CryptoServiceProvider();

try

{

oFileStream = new ream(pathName, ,

, ite);

arrbytHashValue = eHash(oFileStream); //计算指定Stream 对象的哈希值

();

//由以连字符分隔的十六进制对构成的String,其中每一对表示value 中对应的元素;例如“F-2C-4A”

strHashData = ng(arrbytHashValue);

//替换-

strHashData = e("-", "");

strResult = strHashData;

}

catch (ion ex)

{

(e);

}

return strResult;

}