问题描述:MD5加密已过时



          '“FormsAuthentication.HashPasswordForStoringInConfigFile(string, string)”已过时:“

警告   CS0618     recommended alternative is to use the Membership APIs, such as Membership.CreateUser. For ZDSoft.TES.Web   AppHelper.cs

         more information, see http://go.microsoft.com/fwlink/?LinkId=252463.”


发生地点:AppHelper.cs

        public static string EncodeMd5(string str)
        {
            return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5");
        }

解决方法:

     public static string EncodeMd5(string str)
        {
            return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5");
            MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
            byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(str));
            StringBuilder sBuilder = new StringBuilder();
            for (int i = 0; i < data.Length; i++)
            {
                sBuilder.Append(data[i].ToString("x2"));
            }
            return sBuilder.ToString();
        }
01-19 11:14