md5helper.cs

来自「破解的飞信源代码」· CS 代码 · 共 39 行

CS
39
字号
namespace Imps.Client.Utils.Cryptography
{
    using Imps.Client.Utils;
    using System;
    using System.IO;
    using System.Security.Cryptography;

    public class MD5Helper
    {
        public static string GetFileMD5(string filePath)
        {
            string text;
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath");
            }
            using (FileStream inputStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                MD5 md = null;
                try
                {
                    md = new MD5CryptoServiceProvider();
                    md.Initialize();
                    text = ComputeAuthResponse.BinaryToHex(md.ComputeHash(inputStream));
                }
                finally
                {
                    if (md != null)
                    {
                        md.Clear();
                    }
                }
            }
            return text;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?