YouTip LogoYouTip

Php Csprng

# PHP CSPRNG [![Image 3: 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()** - Generates a random string. * **random_int()** - Generates a random integer. * * * ## random_bytes() ### Syntax string random_bytes ( int $length ) ### Parameters * **length** - The number of bytes to return in the random string. ### Return Value * Returns a string, accepting an int parameter representing the number of bytes in the result. ### Example ## Example The output of the above program is: 6f36d48a29 * * * ## random_int() ### Syntax int random_int ( int $min , int $max ) ### Parameters * **min** - The minimum value to be returned, must be greater than or equal to PHP_INT_MIN. * **max** - The maximum value to be returned, must be less than or equal to PHP_INT_MAX. ### Return Value * Returns an int number within the specified range. ### Example ## Example The output of the above program is: 723-64 * * PHP 7 New Features](#)
← R LoopR Data Types β†’