W3cubDocs

/Drupal 8

protected function Schema::hashBase64

protected Schema::hashBase64($data)

Calculates a base-64 encoded, PostgreSQL-safe sha-256 hash per PostgreSQL documentation: 4.1. Lexical Structure.

Parameters

$data: String to be hashed.

Return value

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

File

core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php, line 842

Class

Schema
PostgreSQL implementation of \Drupal\Core\Database\Schema.

Namespace

Drupal\Core\Database\Driver\pgsql

Code

protected function hashBase64($data) {
  $hash = base64_encode(hash('sha256', $data, TRUE));
  // Modify the hash so it's safe to use in PostgreSQL identifiers.
  return strtr($hash, array('+' => '_', '/' => '_', '=' => ''));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Driver!pgsql!Schema.php/function/Schema::hashBase64/8.1.x