R3m/framework Function reference math.random.bytes

{math.random.bytes(Int $length)}

Generates an arbitrary length string of cryptographic random bytes that are suitable for cryptographic use, such as when generating salts, keys or initialization vectors.

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 an Exception will be thrown.

Returns a string containing the requested number of cryptographically secure random bytes.

More information:


Last modified: 2021-06-07

© 2021 universeorange.com