[解决警告]MD5加密已过时

大兔子大兔子 提交于 2019-12-01 10:03:06

问题描述: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();
        }

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!