MD5加密

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Security.Cryptography;
namespace ConsoleApplication1
{
    class Program
    {
        /// <summary>
        /// 返回加密后的字符串
        /// </summary>
        /// <param name="input">input代表要加密的字符串</param>
        /// <returns></returns>
        public static string GetMD5Hash(string input)
        {
            MD5 md5Hash = MD5.Create();
            byte[] data = md5Hash.ComputeHash(Encoding.Default.GetBytes(input));
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 0; i < data.Length; i++)
            {   
                stringBuilder.Append(data[i].ToString("x2"));
            }
            return stringBuilder.ToString();
        }
        static void Main(string[] args)
        {
            string input="hello";
            string output=Program.GetMD5Hash(input);
            Console.WriteLine("加密前:"+input);
            Console.WriteLine("加密后:"+output);
            Console.ReadKey();
        }
    }
}
阅读更多
上一篇利用JS在Table中插入行和列
下一篇javaScript禁止粘贴复制
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭