You are here

public static function Crypt::hashBase64 in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/Utility/Crypt.php \Drupal\Component\Utility\Crypt::hashBase64()

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

Parameters

string $data: String to be hashed.

Return value

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

20 calls to Crypt::hashBase64()
ActionAddForm::buildForm in core/modules/action/src/ActionAddForm.php
ActionAdminManageForm::buildForm in core/modules/action/src/Form/ActionAdminManageForm.php
Form constructor.
AggregatorTestRssController::testFeed in core/modules/aggregator/tests/modules/aggregator_test/src/Controller/AggregatorTestRssController.php
Generates a test feed and simulates last-modified and etags.
AssetDumper::dump in core/lib/Drupal/Core/Asset/AssetDumper.php
The file name for the CSS or JS cache file is generated from the hash of the aggregated contents of the files in $data. This forces proxies and browsers to download new CSS when the CSS changes.
AssetResolver::getCssAssets in core/lib/Drupal/Core/Asset/AssetResolver.php
Returns the CSS assets for the current response's libraries.

... See full list

File

core/lib/Drupal/Component/Utility/Crypt.php, line 129
Contains \Drupal\Component\Utility\Crypt.

Class

Crypt
Utility class for cryptographically-secure string handling routines.

Namespace

Drupal\Component\Utility

Code

public static function hashBase64($data) {
  $hash = base64_encode(hash('sha256', $data, TRUE));

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