MD5加密

来源:互联网 发布:dbc2000数据库64位 编辑:程序博客网 时间:2024/05/23 02:01
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;


namespace MD5Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "123";
            //202cb962ac59075b964b07152d234b70
            //202cb962ac59075b964b07152d234b70
            Console.Write(UseMD5(str));
            Console.ReadKey();
        }


        public static string UseMD5(string str)
        {
            MD5 md5 = MD5.Create();
            byte[] buffer = Encoding.Default.GetBytes(str);
            byte[] md5byte = md5.ComputeHash(buffer);
            string strNew = "";
            for (int i = 0; i < md5byte.Length; i++)
            {
                strNew += md5byte[i].ToString("x2");
            }
            return strNew;
        }
    }
}
0 0
原创粉丝点击