function Crypt::randomBytesBase64
Same name and namespace in other branches
- 8.9.x core/lib/Drupal/Component/Utility/Crypt.php \Drupal\Component\Utility\Crypt::randomBytesBase64()
- 10 core/lib/Drupal/Component/Utility/Crypt.php \Drupal\Component\Utility\Crypt::randomBytesBase64()
- 11.x core/lib/Drupal/Component/Utility/Crypt.php \Drupal\Component\Utility\Crypt::randomBytesBase64()
Returns a URL-safe, base64 encoded string of highly randomized bytes.
Parameters
$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.
16 calls to Crypt::randomBytesBase64()
- CsrfTokenGenerator::get in core/
lib/ Drupal/ Core/ Access/ CsrfTokenGenerator.php - Generates a token based on $value, the user session, and the private key.
- drupal_generate_test_ua in core/
includes/ bootstrap.inc - Generates a user agent string with a HMAC and timestamp for simpletest.
- FormBuilder::prepareForm in core/
lib/ Drupal/ Core/ Form/ FormBuilder.php - Prepares a structured form array.
- FormBuilder::rebuildForm in core/
lib/ Drupal/ Core/ Form/ FormBuilder.php - Constructs a new $form from the information in $form_state.
- FormCache::getCache in core/
lib/ Drupal/ Core/ Form/ FormCache.php - Fetches a form from the cache.
File
-
core/
lib/ Drupal/ Component/ Utility/ Crypt.php, line 64
Class
- Crypt
- Utility class for cryptographically-secure string handling routines.
Namespace
Drupal\Component\UtilityCode
public static function randomBytesBase64($count = 32) {
return str_replace([
'+',
'/',
'=',
], [
'-',
'_',
'',
], base64_encode(random_bytes($count)));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.