PHP Function Reference


The cryptographically secure pseudo-random number generator (CSPRNG) API provides an easy and reliable way to generate crypto-strong random integers and bytes for use within cryptographic contexts.

This exists as of PHP 7.0.0 but there is also a userland implementation for PHP >= 5.2.0.


There is no installation needed to use these functions. These functions are part of the PHP core.

Runtime Configuration

This extension has no configuration directives defined in php.ini.

PHP CSPRNG Functions

random_bytes() Generates cryptographically secure pseudo-random bytes.
random_int() Generates cryptographically secure pseudo-random integers.

PHP CSPRNG Predefined Constants

This extension has no constants defined.