function drupal_get_private_key

Ensures the private key variable used to generate tokens is set.

Return value

The private key.

4 calls to drupal_get_private_key()
drupal_get_token in drupal/core/includes/common.inc
Generates a token based on $value, the user session, and the private key.
image_style_path_token in drupal/core/modules/image/image.module
Generates a token to protect an image style derivative.
WebTestBase::drupalGetToken in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Generate a token for the currently logged in user.
_update_process_fetch_task in drupal/core/modules/update/update.fetch.inc
Processes a task to fetch available update data for a single project.

File

drupal/core/includes/common.inc, line 4014
Common functions that many Drupal modules will need to reference.

Code

function drupal_get_private_key() {
  if (!($key = Drupal::state()
    ->get('system.private_key'))) {
    $key = Crypt::randomStringHashed(55);
    Drupal::state()
      ->set('system.private_key', $key);
  }
  return $key;
}