42 public function __construct($key, callable $comparator, $data, $algo =
'sha256') {
44 $this->comparator = $comparator;
49 if (!is_string($data)) {
50 $data = serialize($data);
63 $bytes = hash_hmac($this->algo, $this->data, $this->key,
true);
75 return call_user_func($this->comparator, $expected_token,
$token);
Exception thrown if an argument is not of the expected type.
matchesToken($token)
Does the MAC match the given token?
getToken()
Get the HMAC token in Base64URL encoding.
Component for creating HMAC tokens.
static encode($bytes)
Encode base 64 URL.
__construct($key, callable $comparator, $data, $algo= 'sha256')
Constructor.