當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crypto::hmacSha1Verify方法代碼示例

本文整理匯總了PHP中Crypto::hmacSha1Verify方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crypto::hmacSha1Verify方法的具體用法?PHP Crypto::hmacSha1Verify怎麽用?PHP Crypto::hmacSha1Verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Crypto的用法示例。


在下文中一共展示了Crypto::hmacSha1Verify方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: unwrap

 /**
  * {@inheritDoc}
  */
 public function unwrap($in, $maxAgeSec)
 {
     //TODO remove this once we have a better way to generate a fake token
     // in the example files
     if (Config::get('allow_plaintext_token') && count(explode(':', $in)) == 6) {
         $data = explode(":", $in);
         $out = array();
         $out['o'] = $data[0];
         $out['v'] = $data[1];
         $out['a'] = $data[2];
         $out['d'] = $data[3];
         $out['u'] = $data[4];
         $out['m'] = $data[5];
     } else {
         //TODO Exception handling like JAVA
         $bin = base64_decode($in);
         $cipherText = substr($bin, 0, strlen($bin) - Crypto::$HMAC_SHA1_LEN);
         $hmac = substr($bin, strlen($cipherText));
         Crypto::hmacSha1Verify($this->hmacKey, $cipherText, $hmac);
         $plain = Crypto::aes128cbcDecrypt($this->cipherKey, $cipherText);
         $out = $this->deserialize($plain);
         $this->checkTimestamp($out, $maxAgeSec);
     }
     return $out;
 }
開發者ID:jkinner,項目名稱:ringside,代碼行數:28,代碼來源:BasicBlobCrypter.php

示例2: unwrap

 /**
  * @see BasicBlobCrypter::unwrap();
  */
 public function unwrap($in, $maxAgeSec)
 {
     if ($this->allowPlaintextToken && count(explode(':', $in)) == 7) {
         $data = explode(":", $in);
         $out = array();
         $out['o'] = $data[0];
         $out['v'] = $data[1];
         $out['a'] = $data[2];
         $out['d'] = $data[3];
         $out['u'] = $data[4];
         $out['m'] = $data[5];
     } else {
         $bin = base64_decode($in);
         if (is_callable('mb_substr')) {
             $cipherText = mb_substr($bin, 0, -Crypto::$HMAC_SHA1_LEN, 'latin1');
             $hmac = mb_substr($bin, mb_strlen($cipherText, 'latin1'), Crypto::$HMAC_SHA1_LEN, 'latin1');
         } else {
             $cipherText = substr($bin, 0, -Crypto::$HMAC_SHA1_LEN);
             $hmac = substr($bin, strlen($cipherText));
         }
         Crypto::hmacSha1Verify($this->hmacKey, $cipherText, $hmac);
         $plain = base64_decode($cipherText);
         if ($this->allowPlaintextToken) {
             $plain = base64_decode($cipherText);
         } else {
             $plain = opShindigCrypto::decrypt($this->cipherKey, $cipherText);
         }
         $out = $this->deserialize($plain);
         $this->checkTimestamp($out, $maxAgeSec);
     }
     return $out;
 }
開發者ID:niryuu,項目名稱:opOpenSocialPlugin,代碼行數:35,代碼來源:opShindigBlobCrypter.class.php

示例3: testHmacSha1Verify

 /**
  * Tests Crypto::hmacSha1Verify()
  */
 public function testHmacSha1Verify()
 {
     $string = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit';
     $key = 'Aliquam erat volutpat';
     $expected = '%16%E7%E0E%22%08%5C%2B48%85d%FE%DE%C7%3A%C3%0D%11c';
     try {
         Crypto::hmacSha1Verify($key, $string, urldecode($expected));
         $success = true;
     } catch (GeneralSecurityException $e) {
         $success = false;
     }
     $this->assertTrue($success);
 }
開發者ID:ahmedadham88,項目名稱:enhanced-social-network,代碼行數:16,代碼來源:CryptoTest.php

示例4: unwrap

 /**
  * {@inheritDoc}
  */
 public function unwrap($in, $maxAgeSec)
 {
     //TODO remove this once we have a better way to generate a fake token in the example files
     if ($this->allowPlaintextToken && count(explode(':', $in)) >= 7) {
         //Parses the security token in the form st=o:v:a:d:u:m:c
         $data = $this->parseToken($in);
         $out = array();
         $out['o'] = $data[0];
         $out['v'] = $data[1];
         $out['a'] = $data[2];
         $out['d'] = $data[3];
         $out['u'] = $data[4];
         $out['m'] = $data[5];
     } else {
         $bin = base64_decode($in);
         if (is_callable('mb_substr')) {
             $cipherText = mb_substr($bin, 0, -Crypto::$HMAC_SHA1_LEN, 'latin1');
             $hmac = mb_substr($bin, mb_strlen($cipherText, 'latin1'), Crypto::$HMAC_SHA1_LEN, 'latin1');
         } else {
             $cipherText = substr($bin, 0, -Crypto::$HMAC_SHA1_LEN);
             $hmac = substr($bin, strlen($cipherText));
         }
         Crypto::hmacSha1Verify($this->hmacKey, $cipherText, $hmac);
         if (!function_exists('mcrypt_module_open') && $this->allowPlaintextToken) {
             $plain = base64_decode($cipherText);
         } else {
             $plain = Crypto::aes128cbcDecrypt($this->cipherKey, $cipherText);
         }
         $out = $this->deserialize($plain);
         $this->checkTimestamp($out, $maxAgeSec);
     }
     return $out;
 }
開發者ID:react-epfl,項目名稱:moodle-shindig,代碼行數:36,代碼來源:BasicBlobCrypter.php

示例5: unwrap

 /**
  * {@inheritDoc}
  */
 public function unwrap($in, $maxAgeSec)
 {
     //TODO remove this once we have a better way to generate a fake token in the example files
     if ($this->allowPlaintextToken && count(explode(':', $in)) == 6) {
         $data = explode(":", $in);
         $out = array();
         $out['o'] = $data[0];
         $out['v'] = $data[1];
         $out['a'] = $data[2];
         $out['d'] = $data[3];
         $out['u'] = $data[4];
         $out['m'] = $data[5];
     } else {
         $bin = base64_decode($in);
         $cipherText = substr($bin, 0, strlen($bin) - Crypto::$HMAC_SHA1_LEN);
         $hmac = substr($bin, strlen($cipherText));
         Crypto::hmacSha1Verify($this->hmacKey, $cipherText, $hmac);
         if (!function_exists('mcrypt_module_open') && $this->allowPlaintextToken) {
             $plain = base64_decode($cipherText);
         } else {
             $plain = Crypto::aes128cbcDecrypt($this->cipherKey, $cipherText);
         }
         $out = $this->deserialize($plain);
         $this->checkTimestamp($out, $maxAgeSec);
     }
     return $out;
 }
開發者ID:dalinhuang,項目名稱:shopexts,代碼行數:30,代碼來源:BasicBlobCrypter.php


注:本文中的Crypto::hmacSha1Verify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。