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

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

    • 分享

      asp.net編程中實(shí)現(xiàn) MD5 加密

       悟靜 2011-09-29
      現(xiàn)在制作的web系統(tǒng)需要用到加密
      依舊選擇md5吧(其實(shí)我也就用過(guò)md5^_^)

      找到了兩種實(shí)現(xiàn)



      /**////
      /// 用md5加密
      ///

      /// 輸入的數(shù)據(jù)
      ///
      public static string MD5(string Sourcein)
      ...{
      MD5CryptoServiceProvider MD5CSP = new MD5CryptoServiceProvider();
      byte[] MD5Source = System.Text.Encoding.UTF8.GetBytes(Sourcein);
      byte[] MD5Out = MD5CSP.ComputeHash(MD5Source);
      return Convert.ToBase64String(MD5Out);
      }

      public static string md5(string str, int code)
      ...{
      if (code == 16) //16位MD5加密(取32位加密的9~25字符)
      ...{
      return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);
      }

      if (code == 32) //32位加密
      ...{
      return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower();
      }
      return "00000000000000000000000000000000";
      }


      現(xiàn)在有兩種方法,第一種是通過(guò)MD5CryptoServiceProvider類對(duì)字節(jié)數(shù)據(jù)進(jìn)行加密

      第二種直接加密以string類型作為參數(shù),這個(gè)直觀些

      不懂兩個(gè)加密的結(jié)果怎么樣??

      TextBox1.Text = MD51("12345");
      TextBox2.Text = MD52("12345", 32);

      分別是md51:gnzLDuqKcGxMNKFokfhOew==

      md52:827ccb0eea8a706c4c34a16891f84e7b

      why?不一樣,用我的直覺判斷第二個(gè)是我經(jīng)常見到的md5加密

      而第一種方式就搞不懂了呵呵

      提示一下

      第二種方式使用.ToLower()是為了與asp中的md5加密兼容;

      與asp兼容還有就是加密中文可能會(huì)遇到編碼問(wèn)題。

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

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多