Crypt::hashBase64

public static Crypt::hashBase64($data)

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.

File

core/lib/Drupal/Component/Utility/Crypt.php, line 70

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);
}
doc_Drupal
2016-10-29 08:59:09
Comments
Leave a Comment

Please login to continue.