for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Zenstruck\JWT\Signer;
use Zenstruck\JWT\Signer;
/**
* @author Alessandro Nadalin <[email protected]>
* @author Kevin Bond <[email protected]>
*/
abstract class HMAC implements Signer
{
* {@inheritdoc}
public function sign($input, $key)
return hash_hmac($this->hashingAlgorithm(), $input, (string) $key, true);
}
public function verify($input, $signature, $key)
if (!function_exists('hash_equals')) {
throw new \RuntimeException('hash_equals is only available in PHP 5.6+, install symfony/polyfill-php56 in PHP 5.4/5.5');
$signedInput = $this->sign($input, $key);
return hash_equals($signedInput, $signature);
* @return string
abstract protected function hashingAlgorithm();