/// <summary>
///MD5 的摘要说明/// </summary>public class MD5{ public MD5() { // //TODO: 在此处添加构造函数逻辑 // }// 本地加密密钥(公钥)
//public const string key = "jd74t5aeq234jl0i"; public const string key = "ZopW1Ege62hsTf32";/// <summary>
/// 用MD5算法加密字符串 /// </summary> /// <param name="srcString">要加密的字符串</param> /// <returns>加密后的字符串</returns> public static string Encrypt(string srcString) { srcString = srcString + key; byte[] b = Encoding.Default.GetBytes(srcString); b = new MD5CryptoServiceProvider().ComputeHash(b); string ret = ""; for (int i = 0; i < b.Length; i++) { ret += b[i].ToString("x2").ToUpper(); } return ret; }/// <summary>
/// 用MD5算法加密字符串(不带密钥) /// </summary> /// <param name="srcString">要加密的字符串</param> /// <returns>加密后的字符串</returns> public static string EncryptWithoutKey(string srcString, Encoding _encoding) { byte[] b = Encoding.UTF8.GetBytes(srcString); byte[] a = Encoding.Convert(Encoding.UTF8, _encoding, b); b = new MD5CryptoServiceProvider().ComputeHash(a); string ret = ""; for (int i = 0; i < b.Length; i++) { ret += b[i].ToString("x2").ToUpper(); } return ret; }}