📜  C# 计算文件的 MD5 校验和 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:58.281000             🧑  作者: Mango

代码示例1
using System.IO;
using System.Security.Cryptography.MD5;

static string CalculateMD5(string filename)
{
    using (var md5 = MD5.Create())
    {
        using (var stream = File.OpenRead(filename))
        {
            var hash = md5.ComputeHash(stream);
            return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
        }
    }
}