C#端
using System;
using System.IO;
using System.Security.Cryptography;
namespace 计算文件的MD5值
{
class MD5_Helper
{
///
/// 文件MD5校验
///
/// 文件绝对路径
/// MD5校验码
public string getMD5Hash(string pathName)
{
string strResult = "";
string strHashData = "";
byte[] arrbytHashValue;
FileStream oFileStream = null;
MD5CryptoServiceProvider oMD5Hasher =
new MD5CryptoServiceProvider();
try
{
oFileStream = new FileStream(pathName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
arrbytHashValue = oMD5Hasher.ComputeHash(oFileStream);//计算指定Stream 对象的哈希值
oFileStream.Close();
//由以连字符分隔的十六进制对构成的String,其中每一对表示value 中对应的元素;例如“F-2C-4A”
strHashData