.NET Framework md5的简单用法

在MSDN上找MD5的示例费劲死了,现在写个简单的,

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            MD5 myMD5 = MD5.Create();
            Stream myStream = new FileStream(@"E:\Software\incubating-log4net-1.2.10.zip", FileMode.OpenOrCreate);
            byte[] myByte = myMD5.ComputeHash(myStream);
            string pwd = "";
            for (int i = 0; i < myByte.Length; i++)
            {
                // 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
                pwd = pwd + myByte[i].ToString("x");
            }

            Console.WriteLine(pwd);
            
        }
    }
}

原文地址:https://www.cnblogs.com/linc09/p/1590943.html