public static string Std_Encrypt_MD5(string AppKey) { MD5 MD5 = new MD5CryptoServiceProvider(); byte[] datSource = Encoding.GetEncoding("gb2312").GetBytes(AppKey); byte[] newSource = MD5.ComputeHash(datSource); Console.WriteLine(newSource.Length); StringBuilder sb = new StringBuilder(32); for (int i = 0; i < newSource.Length; i++) { sb.Append(newSource[i].ToString("x").PadLeft(2, '0'));//ToString("x")是吧相应的字节转换为16进制的 PadLeft是在转换后只有一个数字的比如(a(十进制的10)左边添加一个0) } string crypt = sb.ToString(); Console.WriteLine(crypt.Length); return crypt; }