Random\Engine\Secure::generate
(PHP 8 >= 8.2.0)
Random\Engine\Secure::generate — Generate cryptographically secure randomness
Description
public Random\Engine\Secure::generate(): string
The sources of randomness used for this function are as follows:
-
On Windows,
» CryptGenRandom()
will always be used. As of PHP 7.2.0, the
» CNG-API
will always be used instead.
-
On Linux, the
» getrandom(2)
syscall will be used if available.
-
On other platforms, /dev/urandom will be used.
-
If none of the aforementioned sources are available, then a
Random\RandomException will be thrown.
Parameters
This function has no parameters.
Return Values
A string containing PHP_INT_SIZE
cryptographically secure random bytes.