random_bytes to generate cryptographically secure random bytes
echo random_bytes($length);
$length : Length of the random string returned as bytes.
Generates cryptographically secure pseudo-random bytes which can be used as Salts, keys etc.
Available in PHP 7
Example
$str=random_bytes(7);
echo bin2hex($str);
Output ( Refresh this page to to see how the random number changes )
6c4f05d006eeff
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com
|