SecureRandom

class OC\Security\SecureRandom
Class SecureRandom provides a wrapper around the random_int function to generate
secure random strings. For PHP 7 the native CSPRNG is used, older versions do
use a fallback.
Usage:
\OC::$server->getSecureRandom()->generate(10);
Source:lib/private/Security/SecureRandom.php#42
Implements:OCP\Security\ISecureRandom

Methods

public OC\Security\SecureRandom::generate($length, $characters=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/)
Generate a random string of specified length.
Source:

lib/private/Security/SecureRandom.php#50

Parameters:
  • $length (int) The length of the generated string
  • $characters (string) An optional list of characters to use if no character list is

specified all valid base64 characters are used.

Returns:

string