本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}