本文整理汇总了PHP中Crypto::hmacSha1方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypto::hmacSha1方法的具体用法?PHP Crypto::hmacSha1怎么用?PHP Crypto::hmacSha1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypto
的用法示例。
在下文中一共展示了Crypto::hmacSha1方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hmacSha1Verify
public static function hmacSha1Verify($key, $in, $expected)
{
$hmac = Crypto::hmacSha1($key, $in);
if ($hmac != $expected) {
throw new GeneralSecurityException("HMAC verification failure");
}
}
示例2: wrap
/**
* {@inheritDoc}
*/
public function wrap(array $in)
{
$encoded = $this->serializeAndTimestamp($in);
$cipherText = Crypto::aes128cbcEncrypt($this->cipherKey, $encoded);
$hmac = Crypto::hmacSha1($this->hmacKey, $cipherText);
$b64 = base64_encode($cipherText . $hmac);
return $b64;
}
示例3: testHmacSha1
/**
* Tests Crypto::hmacSha1()
*/
public function testHmacSha1()
{
$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';
$hmac = urlencode(Crypto::hmacSha1($key, $string));
$this->assertEquals($expected, $hmac);
}
示例4: wrap
/**
* {@inheritDoc}
*/
public function wrap(array $in)
{
$encoded = $this->serializeAndTimestamp($in);
if (!function_exists('mcrypt_module_open') && $this->allowPlaintextToken) {
$cipherText = base64_encode($encoded);
} else {
$cipherText = Crypto::aes128cbcEncrypt($this->cipherKey, $encoded);
}
$hmac = Crypto::hmacSha1($this->hmacKey, $cipherText);
$b64 = base64_encode($cipherText . $hmac);
return $b64;
}
示例5: wrap
/**
* @see BasicBlobCrypter::warp()
*/
public function wrap(array $in)
{
$encoded = $this->serializeAndTimestamp($in);
if ($this->allowPlaintextToken) {
$cipherText = base64_encode($encoded);
} else {
$cipherText = opShindigCrypto::encrypt($this->cipherKey, $encoded);
}
$hmac = Crypto::hmacSha1($this->hmacKey, $cipherText);
$b64 = base64_encode($cipherText . $hmac);
return $b64;
}