Same name and namespace in other branches
  1. 7.x includes/bootstrap.inc \drupal_random_key()

Returns a URL-safe, base64 encoded string of highly randomized bytes (over the full 8-bit range).

Parameters

$byte_count: The number of random bytes to fetch and base64 encode.

Return value

string The base64 encoded result will have a length of up to 4 * $byte_count.

3 calls to drupal_random_key()
drupal_get_private_key in includes/common.inc
Ensure the private key variable used to generate tokens is set.
drupal_rebuild_form in includes/form.inc
Retrieves a form, caches it and processes it with an empty $_POST.
form_get_cache in includes/form.inc
Fetch a form from cache.

File

includes/bootstrap.inc, line 1391
Functions that need to be loaded on every Drupal request.

Code

function drupal_random_key($byte_count = 32) {
  return drupal_base64_encode(drupal_random_bytes($byte_count));
}