using System; using System.Text; //System.Security下加密算法的命名空间 using System.Security.Cryptography; namespace Util { public class MD5Encryption { /// <summary> /// MD5十六位的加密 /// </summary> /// <param name="password"></param> public static string GetMD5Str(string password) { var md5 = new MD5CryptoServiceProvider();//很奇怪 这个类竟然没有智能提示 string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(password)), 4, 8); t2.Replace("-",""); return t2; } } }