码迷,mamicode.com
首页 > 其他好文 > 详细

md5加密

时间:2015-08-28 09:30:51      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:

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

namespace ConsoleApplication2
{
    class Program
    {
        /// <summary>
        /// md5加密
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            string str = "", str1 = "admin";
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] byets = System.Text.Encoding.UTF8.GetBytes(str1);
            byets = md5.ComputeHash(byets);
            for (int i = 0; i < byets.Length; i++)
            {
                // x2  代表转换为16进制  大写X 代表把字母转成大写
                str += byets[i].ToString("x2");
            }

            Console.WriteLine(str);
            Console.ReadKey();
        }
    }
}

 

md5加密

标签:

原文地址:http://www.cnblogs.com/xh0626/p/4765506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!