Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Crypt.php

function Crypt::randomBytesBase64

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

Parameters

int $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.

21 calls to Crypt::randomBytesBase64()
BigPipe::sendNoJsPlaceholders in core/modules/big_pipe/src/Render/BigPipe.php
Sends no-JS BigPipe placeholders' replacements as embedded HTML responses.
BigPipe::sendPreBody in core/modules/big_pipe/src/Render/BigPipe.php
Sends everything until just before </body>.
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 tests.
FormBuilder::prepareForm in core/lib/Drupal/Core/Form/FormBuilder.php
Prepares a structured form array.

... See full list

File

core/lib/Drupal/Component/Utility/Crypt.php, line 64

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(random_bytes($count)));
}
RSS feed
Powered by Drupal