zoukankan      html  css  js  c++  java
  • FormsAuthentication.HashPasswordForStoringInConfigFile 方法已过时

    老方法代码

    var result=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("要加密的字符串", "MD5");

    新的方法代码

    using System.Security.Cryptography; 
    string strEncrypt=string.Empty;
    using (var md5 = MD5.Create())
                    {
                        var result = md5.ComputeHash(Encoding.UTF8.GetBytes("要加密的字符串"));
                        var strResult = BitConverter.ToString(result);
                        strEncrypt= strResult.Replace("-", "");
                    }

    需要注意的是 ComputeHash 中的参数需要使用 UTF8 格式编码才能保持同 FormsAuthentication.HashPasswordForStoringInConfigFile 方法的结果一致。

  • 相关阅读:
    离线缓存之RNCachingURLProtocol解析
    Element demo解析
    GHUnit+OCMock
    XCTest+XCTool
    day1`4整理
    day4 笔记
    day3
    day1
    day2
    Python学习(二)——Python基础
  • 原文地址:https://www.cnblogs.com/qingjiawen/p/15064346.html
Copyright © 2011-2022 走看看