Rand
class Rand (View source)
Class for generating random numbers
Methods
Generates pseudo random bytes
Mixes bytes in $buf into PRNG state
Cleans up PRNG state
Reads a number of bytes from file $filename and adds them to the PRNG. If max_bytes is non-negative, up to to max_bytes are read; if $max_bytes is negative, the complete file is read
Writes a number of random bytes (currently 1024) to file $filename which can be used to initializethe PRNG by calling Crypto\Rand::loadFile() in a later session
Details
static string
generate(int $num, bool $must_be_strong = true, bool $returned_strong_result = true)
Generates pseudo random bytes
static null
seed(string $buf, float $entropy)
Mixes bytes in $buf into PRNG state
static null
cleanup()
Cleans up PRNG state
static int
loadFile(string $filename, int $max_bytes = -1)
Reads a number of bytes from file $filename and adds them to the PRNG. If max_bytes is non-negative, up to to max_bytes are read; if $max_bytes is negative, the complete file is read
static int
writeFile(string $filename)
Writes a number of random bytes (currently 1024) to file $filename which can be used to initializethe PRNG by calling Crypto\Rand::loadFile() in a later session