You are here

function _cdn_hmac_base64 in CDN 6.2

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

Based on Drupal 7's drupal_hmac_base64().

2 calls to _cdn_hmac_base64()
cdn_basic_farfuture_download in ./cdn.basic.farfuture.inc
cdn_file_url_alter in ./cdn.module
Implementation of hook_file_url_alter().

File

./cdn.basic.farfuture.inc, line 511
Far Future expiration setting for basic mode.

Code

function _cdn_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(
    '+' => '-',
    '/' => '_',
    '=' => '',
  ));
}