MD5加密在Net framework 4.5下面会警告过时
//4.0,4.5中过时(编译器警告)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
users.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txt_pwd.Value.ToString().Trim(), "SHA1").ToUpper(); //SHA1加密,40位 users.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txt_pwd.Value.ToString().Trim(), "MD5").ToUpper(); //MD5加密,32位
解决方案:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
users.Password = Md5Hash(txt_Phone.Value.ToString().Trim()); public String Md5Hash(String pwd) { MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider(); byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(pwd)); StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.Length; i++) { sb.Append(data[i].ToString("x2")); } return sb.ToString(); }