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

使用MD5加密字符串

时间:2019-06-04 22:35:48      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:com   bsp   字符串   ons   效果   col   加密   tostring   span   

实现效果:

  技术图片

实现代码:

static void Main(string[] args)
        {
            Console.WriteLine("Enter a string to MD5 encryption...\n");
            while (true)
            {
                Console.WriteLine(GetMD5(Console.ReadLine()));   
            }
        }
        static string GetMD5(string str)
        {
            byte[] bts1 = Encoding.Default.GetBytes(str);
            MD5 md5 = MD5.Create();
            StringBuilder result = new StringBuilder();
            byte[] bts2 = md5.ComputeHash(bts1);
            foreach (byte item in bts2)
            {
                result.Append(item.ToString("x2"));
            }
            return result.ToString();
        }

 

使用MD5加密字符串

标签:com   bsp   字符串   ons   效果   col   加密   tostring   span   

原文地址:https://www.cnblogs.com/feiyucha/p/10976436.html

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