You are here

public static function Crypt::randomBytesBase64 in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Utility/Crypt.php \Drupal\Component\Utility\Crypt::randomBytesBase64()

Returns a URL-safe, base64 encoded string of highly randomized bytes.

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.

See also

\Drupal\Component\Utility\Crypt::randomBytes()

21 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.
CsrfTokenGeneratorTest::setupDefaultExpectations in core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
Set up default expectations on the mocks.
CsrfTokenGeneratorTest::testGenerateSeedOnGet in core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
Tests that a new token seed is generated upon first use.
drupal_generate_test_ua in core/includes/bootstrap.inc
Generates a user agent string with a HMAC and timestamp for simpletest.
drupal_install_config_directories in core/includes/install.inc
Creates the config directory and ensures it is operational.

... See full list

File

core/lib/Drupal/Component/Utility/Crypt.php, line 189
Contains \Drupal\Component\Utility\Crypt.

Class

Crypt
Utility class for cryptographically-secure string handling routines.

Namespace

Drupal\Component\Utility

Code

public static function randomBytesBase64($count = 32) {
  return str_replace([
    '+',
    '/',
    '=',
  ], [
    '-',
    '_',
    '',
  ], base64_encode(static::randomBytes($count)));
}