W3cubDocs

/Drupal 8

public static function Crypt::randomBytesBase64

public static Crypt::randomBytesBase64($count = 32)

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 The base64 encoded result will have a length of up to 4 * $count.

See also

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

File

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

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)));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!Crypt.php/function/Crypt::randomBytesBase64/8.1.x