乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      糾正:HashPasswordForStoringInConfigFile中的Md5算法并非常用的Md5算法

       aaie_ 2014-07-20

      本來我也以為System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile中的MD5和常用的一樣

      可今天一試,結(jié)果有很大不同,
      比如test,HashPasswordForStoringInConfigFile編碼成
      C8059E2EC7419F590E79D7F1B774BFE6
      而應(yīng)該是098f6bcd4621d373cade4e832627b4f6


      而且不同的機(jī)器不同的結(jié)果,有些結(jié)果正確
      一看MSDN的解釋,原來是
      Given a password and a string identifying the hash type, this routine produces a hash password suitable for storing in a configuration file.

      為了和以前的代碼兼容和平臺兼容,只好自己重新寫了MD5的算法,利用System.Security.Cryptography.MD5CryptoServiceProvider
      代碼如下,大家執(zhí)行一下就知道了,我就不多說了。


         <script language="C#" runat="server">
         string qswhMD5(string str){
           /************qiushuiwuhen(2002-9-27)***************/
           byte[] b=System.Text.Encoding.Default.GetBytes(str);
           b=new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(b);
           string ret="";
           for(int i=0;i<b.Length;i++)
            ret+=b[i].ToString("x").PadLeft(2,'0');
           return ret;
         }
         public void encryptString(Object sender, EventArgs e)
         {
           myMD5.Text=qswhMD5(txtClear.Text);
           MD5.Text =System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtClear.Text, "MD5") ;
         }
         </script>
         <body onload=document.all.txtClear.select();>
         <form runat="server">
          明文:<asp:Textbox id="txtClear" runat="server" />
          <asp:Button runat="server" text="Md5摘要" onClick="encryptString" ID="Button1" />
          <br/>通常用的 MD5:
          <br/><asp:label id="myMD5" runat="server" /> <br/>
          <br/>HashPasswordForStoringInConfigFile中的 MD5:
          <br/><asp:label id="MD5" runat="server" />
         </form>


        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多