function drupal_hmac_base64

cis7 bootstrap.inc drupal_hmac_base64($data, $key)
cle7 bootstrap.inc drupal_hmac_base64($data, $key)
elmsmedia7 bootstrap.inc drupal_hmac_base64($data, $key)
icor7 bootstrap.inc drupal_hmac_base64($data, $key)
meedjum_blog7 bootstrap.inc drupal_hmac_base64($data, $key)
mooc7 bootstrap.inc drupal_hmac_base64($data, $key)

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

Parameters

string $data: String to be validated with the hmac.

string $key: A secret string key.

Return value

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

8 calls to drupal_hmac_base64()
DrupalWebTestCase::drupalGetToken in modules/simpletest/drupal_web_test_case.php
Generate a token for the currently logged in user.
drupal_generate_test_ua in includes/bootstrap.inc
Generates a user agent string with a HMAC and timestamp for simpletest.
drupal_get_token in includes/common.inc
Generates a token based on $value, the user session, and the private key.
drupal_valid_test_ua in includes/bootstrap.inc
Returns the test prefix if this is an internal request from SimpleTest.
file_entity_get_download_token in sites/all/modules/ulmus/file_entity/file_entity.module

... See full list

File

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

Code

function drupal_hmac_base64($data, $key) {
  // Casting $data and $key to strings here is necessary to avoid empty string
  // results of the hash function if they are not scalar values. As this
  // function is used in security-critical contexts like token validation it is
  // important that it never returns an empty string.
  $hmac = base64_encode(hash_hmac('sha256', (string) $data, (string) $key, TRUE));
  // Modify the hmac so it's safe to use in URLs.
  return strtr($hmac, array('+' => '-', '/' => '_', '=' => ''));
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.