System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string, string)已過時的解決辦法


FormsAuthentication.HashPasswordForStoringInConfigFile 方法是一個在.NET 4.5中已經廢棄不用的API,參見:

https://msdn.microsoft.com/zh-cn/library/system.web.security.formsauthentication.hashpasswordforstoringinconfigfile(v=vs.110).aspx

 

This is a solution for SH1 variant.

     public static string GetSwcSH1(string value)
     {
        SHA1 algorithm = SHA1.Create();
        byte[] data = algorithm.ComputeHash(Encoding.UTF8.GetBytes(value));
        string sh1 = "";
        for (int i = 0; i < data.Length; i++)
        {
            sh1 += data[i].ToString("x2").ToUpperInvariant();
        }
        return sh1;
     }

For MD5 you only change algorithm to:

MD5 algorithm = MD5.Create();

參考:http://stackoverflow.com/questions/13527277/drop-in-replacement-for-formsauthentication-hashpasswordforstoringinconfigfile


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM