Neos\Flow\Security\Cryptography\HashService::generateHmac PHP 메소드

generateHmac() 공개 메소드

Generate a hash (HMAC) for a given string
public generateHmac ( string $string ) : string
$string string The string for which a hash should be generated
리턴 string The hash of the string
    public function generateHmac($string)
    {
        if (!is_string($string)) {
            throw new InvalidArgumentForHashGenerationException('A hash can only be generated for a string, but "' . gettype($string) . '" was given.', 1255069587);
        }
        return hash_hmac('sha1', $string, $this->getEncryptionKey());
    }

Usage Example

 /**
  * @test
  */
 public function generatedHashReturnsAHashOf40Characters()
 {
     $hash = $this->hashService->generateHmac('asdf');
     $this->assertSame(40, strlen($hash));
 }