Neos\Flow\Security\Cryptography\HashService::validateHmac PHP Method

validateHmac() public method

Tests if a string $string matches the HMAC given by $hash.
public validateHmac ( string $string, string $hmac ) : boolean
$string string The string which should be validated
$hmac string The hash of the string
return boolean TRUE if string and hash fit together, FALSE otherwise.
    public function validateHmac($string, $hmac)
    {
        return $this->generateHmac($string) === $hmac;
    }

Usage Example

 /**
  * @test
  */
 public function generatedHashWillNotBeValidatedIfHashHasBeenChanged()
 {
     $string = 'asdf';
     $hash = 'myhash';
     $this->assertFalse($this->hashService->validateHmac($string, $hash));
 }