function CsrfTokenGenerator::computeToken

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Access/CsrfTokenGenerator.php \Drupal\Core\Access\CsrfTokenGenerator::computeToken()
  2. 8.9.x core/lib/Drupal/Core/Access/CsrfTokenGenerator.php \Drupal\Core\Access\CsrfTokenGenerator::computeToken()
  3. 10 core/lib/Drupal/Core/Access/CsrfTokenGenerator.php \Drupal\Core\Access\CsrfTokenGenerator::computeToken()

Generates a token based on $value, the token seed, and the private key.

Parameters

string $seed: The per-session token seed.

string $value: (optional) An additional value to base the token on.

Return value

string A 43-character URL-safe token for validation, based on the token seed, the hash salt provided by Settings::getHashSalt(), and the site private key.

See also

\Drupal\Core\Site\Settings::getHashSalt()

2 calls to CsrfTokenGenerator::computeToken()
CsrfTokenGenerator::get in core/lib/Drupal/Core/Access/CsrfTokenGenerator.php
Generates a token based on $value, the user session, and the private key.
CsrfTokenGenerator::validate in core/lib/Drupal/Core/Access/CsrfTokenGenerator.php
Validates a token based on $value, the user session, and the private key.

File

core/lib/Drupal/Core/Access/CsrfTokenGenerator.php, line 114

Class

CsrfTokenGenerator
Generates and validates CSRF tokens.

Namespace

Drupal\Core\Access

Code

protected function computeToken($seed, $value = '') {
    return Crypt::hmacBase64($value, $seed . $this->privateKey
        ->get() . Settings::getHashSalt());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.