控制台MD5加密

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

namespace 控制台
{
    class Program
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine();
            Console.WriteLine(getmd5(s));
            Console.ReadKey();
        }
        public static string getmd5(string s)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] data = Encoding.Default.GetBytes(s);
            byte[] md5data = md5.ComputeHash(data);
            StringBuilder sb = new StringBuilder();
            foreach (byte item in md5data)
            {
                sb.Append(item.ToString("x2"));
            }
            return sb.ToString();
        }
    }
}

你可能感兴趣的:(控制台MD5加密)