/// <summary> /// MD5加密 /// </summary> /// <param name="strText">待加密字符串</param> /// <returns>加密后字符串</returns> public static string MD5Encrypt(string strText) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] targetData = md5.ComputeHash(Encoding.UTF8.GetBytes(strText)); string byte2String = null; for (int i = 0; i < targetData.Length; i++) { byte2String += targetData[i].ToString("x2"); } return byte2String.ToUpper(); }