You are here

public function CryptTest::testHmacBase64 in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/CryptTest.php \Drupal\Tests\Component\Utility\CryptTest::testHmacBase64()
  2. 9 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 46

Class

CryptTest
Tests random byte generation.

Namespace

Drupal\Tests\Component\Utility

Code

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