首页 > 代码库 > c#字符串MD5加密GetMD5Hash

c#字符串MD5加密GetMD5Hash

/// <summary>        /// 把字符转换成MD5        /// </summary>        /// <param name="input"></param>        /// <returns></returns>        public static string GetMD5Hash(String str)        {                   //把字符串转换成字节数组                   byte[] buffer = Encoding.Default.GetBytes(str);                  MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();                   //md5加密                   byte[] cryptBuffer = md5.ComputeHash(buffer);                   string s = "";                   //把每一个字节 0-255,转换成两位16进制数                        for (int i = 0; i < cryptBuffer.Length; i++)                   {                           //大X转黄的是大写字母,小X转换的是小写字母                           s += cryptBuffer[i].ToString("x2");                   }              return s;        } 

 转自:http://www.nbcoder.net/thread-271-1-1.html

c#字符串MD5加密GetMD5Hash