MD5函数(公共方法)
1 #region MD5函数 2 /// <summary> 3 /// MD5函数 4 /// </summary> 5 /// <param name="str">原始字符串</param> 6 /// <returns>MD5结果</returns> 7 public static string MD5(string str) 8 { 9 byte[] b = encoding.GetBytes(str); 10 b = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(b); 11 string ret = ""; 12 for (int i = 0; i < b.Length; i++) 13 { 14 ret += b[i].ToString("x").PadLeft(2, '0'); 15 } 16 return ret; 17 } 18 #endregion