Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP CSPRNG

PHP CSPRNG

PHP 7 New Features PHP 7 New Features

CSPRNG (Cryptographically Secure Pseudo-Random Number Generator).

PHP 7 provides a simple mechanism to generate cryptographically strong random numbers by introducing several CSPRNG functions.


random_bytes()

Syntax format



string random_bytes ( int $length )

Parameters

Return Value

Example

Example

The output of the above program is:



6f36d48a29


random_int()

Syntax format



int random_int ( int $min , int $max )

Parameters

Return Value

Example

Example

The output of the above program is:



723

-64


PHP 7 New Features PHP 7 New Features