本文整理匯總了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;
}