/// <summary> /// MD5加密 /// </summary> /// <param name="s"></param> /// <returns></returns> public static string Md5Sign(string s) { return GenerateMd5Sign(s, Encoding.Default); } /// <summary> /// 生成的MD5加密的字符串 /// </summary> /// <param name="s">代加密字符串</param> /// <param name="inputCharset">字符编码</param> /// <returns></returns> public static string GenerateMd5Sign(string s, Encoding inputCharset) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] t = md5.ComputeHash(inputCharset.GetBytes(s)); var sb = new StringBuilder(32); for (int i = 0; i < t.Length; i++) { sb.Append(t[i].ToString("x").PadLeft(2, '0')); } return sb.ToString().ToUpper(); }