function drupal_hmac_base64

Calculates a base-64 encoded, URL-safe sha-256 hmac.

Parameters

$data: String to be validated with the hmac.

$key: A secret string key.

Return value

A base-64 encoded sha-256 hmac, with + replaced with -, / with _ and any = padding characters removed.

6 calls to drupal_hmac_base64()
drupal_generate_test_ua in drupal/core/includes/bootstrap.inc
Generates a user agent string with a HMAC and timestamp for simpletest.
drupal_get_token in drupal/core/includes/common.inc
Generates a token based on $value, the user session, and the private key.
drupal_valid_test_ua in drupal/core/includes/bootstrap.inc
Returns the test prefix if this is an internal request from SimpleTest.
user_pass_rehash in drupal/core/modules/user/user.module
Creates a unique hash value for use in time-dependent per-user URLs.
WebTestBase::drupalGetToken in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Generate a token for the currently logged in user.

... See full list

File

drupal/core/includes/bootstrap.inc, line 1982
Functions that need to be loaded on every Drupal request.

Code

function drupal_hmac_base64($data, $key) {
  $hmac = base64_encode(hash_hmac('sha256', $data, $key, TRUE));

  // Modify the hmac so it's safe to use in URLs.
  return strtr($hmac, array(
    '+' => '-',
    '/' => '_',
    '=' => '',
  ));
}