function CryptTest::testHmacBase64

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/CryptTest.php \Drupal\Tests\Component\Utility\CryptTest::testHmacBase64()
  2. 8.9.x core/tests/Drupal/Tests/Component/Utility/CryptTest.php \Drupal\Tests\Component\Utility\CryptTest::testHmacBase64()
  3. 10 core/tests/Drupal/Tests/Component/Utility/CryptTest.php \Drupal\Tests\Component\Utility\CryptTest::testHmacBase64()

Tests HMAC generation.

@dataProvider providerTestHmacBase64 @covers ::hmacBase64

Parameters

string $data: Data to hash.

string $key: Key to use in hashing process.

string $expected_hmac: Expected result from hashing $data using $key.

File

core/tests/Drupal/Tests/Component/Utility/CryptTest.php, line 48

Class

CryptTest
Tests random byte generation.

Namespace

Drupal\Tests\Component\Utility

Code

public function testHmacBase64($data, $key, $expected_hmac) : void {
    $hmac = Crypt::hmacBase64($data, $key);
    $this->assertEquals($expected_hmac, $hmac, 'The correct hmac was not calculated.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.