MD5加密

MD5加密算法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace MD5 {
    class Program {
        static void Main(string[] args) {
            string s = GetMD5("jtahstu");
            Console.WriteLine(s);
            Console.ReadKey();
        }

        public static string GetMD5(string str) {
            MD5 md5 = MD5.Create();
            byte[] buffer = Encoding.GetEncoding("GBK").GetBytes(str);
            byte[] MD5Buffer = md5.ComputeHash(buffer);
            string strNew = "";
            for (int i = 0; i < MD5Buffer.Length; i++) {
                strNew += MD5Buffer[i].ToString("x2");
            }
            return strNew;
        }
    }
}