Example #1
0
 /**
  * Determine if the MAC for the given payload is valid.
  *
  * @param  array $payload
  * @return bool
  *
  * @throws \RuntimeException
  */
 protected function validMac(array $payload)
 {
     $bytes = (new SecureRandom())->nextBytes(16);
     $calcMac = hash_hmac('sha256', $this->hash($payload['iv'], $payload['value']), $bytes, true);
     return StringUtils::equals(hash_hmac('sha256', $payload['mac'], $bytes, true), $calcMac);
 }