.Net常用普通加密方法
/// <summary> /// 字符串Hash加密 /// </summary> /// <param name="codeName">编码类型</param> /// <param name="sourceString">需要加密的字符串</param> /// <returns>MD5加密后字符串</returns> public static string HashString(string sourceString) { byte[] source = md5.ComputeHash(Encoding.GetEncoding("gb2312").GetBytes(sourceString)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < source.Length; i++) { sBuilder.Append(source[i].ToString("x")); } return sBuilder.ToString(); }