function CryptTest::testHmacBase64

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Utility/CryptTest.php \Drupal\Tests\Component\Utility\CryptTest::testHmacBase64()
  2. 10 core/tests/Drupal/Tests/Component/Utility/CryptTest.php \Drupal\Tests\Component\Utility\CryptTest::testHmacBase64()
  3. 11.x 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.');
}

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