You are here

function xmlsitemap_drupal_hash_base64 in XML sitemap 6.2

Backport of drupal_hash_base64() from Drupal 7.

Calculate a base-64 encoded, URL-safe sha-256 hash.

Parameters

$data: String to be hashed.

Return value

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

1 call to xmlsitemap_drupal_hash_base64()
xmlsitemap_sitemap_get_context_hash in ./xmlsitemap.module

File

./xmlsitemap.module, line 1684
Main file for the xmlsitemap module.

Code

function xmlsitemap_drupal_hash_base64($data) {
  if (function_exists('hash')) {
    $hash = base64_encode(hash('sha256', $data, TRUE));
  }
  else {
    $hash = base64_encode(sha1($data, TRUE));
  }

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