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

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

    • 分享

      OAuth協(xié)議中的HMAC_SHA1算法

       實力決定地位 2012-03-30
       本人抄襲一篇java進行改變成C#的。。運行結(jié)構(gòu)完全和java一樣所以證明完全沒有問題。。盡心的用
      public static byte[] getHmacSHA1(String data, String key)
              {

                  byte[] ipadArray = new byte[64];
                  byte[] opadArray = new byte[64];
                  byte[] keyArray = new byte[64];
                  System.Security.Cryptography.SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();

                 // SHA1 sha1 = null;
                  int ex = key.Length;
                  if (key.Length > 64)
                  {
                      byte[] temp = sha1.ComputeHash(strToToHexByte(key));
                      ex = temp.Length;
                      for (int i = 0; i < ex; i++)
                      {
                          keyArray[i] = temp[i];
                      }
                  }
                  else
                  {
                      byte[] temp = strToToHexByte(key);
                      for (int i = 0; i < temp.LongLength; i++)
                      {
                          keyArray[i] = temp[i];
                      }
                  }

                  for (int i = ex; i < 64; i++)
                  {
                      keyArray[i] = 0;
                  }
                  for (int j = 0; j < 64; j++)
                  {
                      ipadArray[j] = (byte)(keyArray[j] ^ 0x36);
                      opadArray[j] = (byte)(keyArray[j] ^ 0x5C);
                  }
                  byte[] tempResult = sha1.ComputeHash(join(ipadArray, strToToHexByte(data)));

                  return sha1.ComputeHash(join(opadArray, tempResult));

       

              }

              private static byte[] join(byte[] b1, byte[] b2)
              {
                  int length = b1.Length + b2.Length;
                  byte[] newer = new byte[length];
                  for (int i = 0; i < b1.LongLength; i++)
                  {
                      newer[i] = b1[i];
                  }
                  for (int i = 0; i < b2.LongLength; i++)
                  {
                      newer[i + b1.LongLength] = b2[i];
                  }
                  return newer;
              }
      調(diào)用的時候轉(zhuǎn)換成base64
      byte[] sb= HMAC_SHA1.getHmacSHA1("456", "123");
      Convert.ToBase64String(sb).
      輸出結(jié)果:arl7onB4MoLePp7oTLNSrhxAOWw=

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

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多