Skip navigation
Help

drupal_hmac_base64

7 bootstrap.inc drupal_hmac_base64($data, $key)

Calculate 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()

File

drupal/includes/bootstrap.inc, line 1718
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('+' => '-', '/' => '_', '=' => ''));
}