function 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 A base-64 encoded string, with + replaced with -, / with _ and any = padding characters removed.
13 calls to drupal_random_key()
- drupal_get_private_key in includes/
common.inc - Ensures the private key variable used to generate tokens is set.
- drupal_prepare_form in includes/
form.inc - Prepares a structured form array.
- drupal_rebuild_form in includes/
form.inc - Constructs a new $form from the information in $form_state.
- drupal_session_initialize in includes/
session.inc - Initializes the session handler, starting a session if needed.
- drupal_session_regenerate in includes/
session.inc - Called when an anonymous user becomes authenticated or vice-versa.
File
-
includes/
bootstrap.inc, line 2291
Code
function drupal_random_key($byte_count = 32) {
return drupal_base64_encode(drupal_random_bytes($byte_count));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.