Class Prng

Description

class Prng

This class provides a simple interface to two character devices, the rand() function and the mt_rand() function. The /dev/random character device is suitable for use when very high quality randomness is desired. The /dev/urandom character device will result in randomness that is merely cryptographically strong. The main difference between the two is that /dev/random is blocking and /dev/urandom is non-blocking. The rand() function uses the libc random number generator. However, mt_rand() is a drop-in replacement for rand() that uses a random number generator with known characteristics using the Mersenne Twister, that will produce randomnumbers four times faster than what the average libc rand() provides.

Located in /prng.class.php (line 27)


	
			
Method Summary
mixed GetPseudoRandomValue (source $source, [length $length = 8])
Methods
GetPseudoRandomValue (line 44)

function GetPseudoRandomValue()

This method retrieves random bits of entropy using a Pseudo-Random Number Generator (PRNG) device or function. The format of the random bits is determined by first converting them to hexadecimal format and then converting them to decimal format byte by byte for /dev/random and /dev/urandom. Furthermore, since values are converted from binary to decimal one at a time, the RAND_MAX (2147483647) constraint does not limit our ability to generate very long random numbers.

  • return: Random number|FALSE
  • access: public
mixed GetPseudoRandomValue (source $source, [length $length = 8])
  • source $source: Random source of entropy
  • length $length: Length of entropy in bytes

Documentation generated on Thu, 9 Sep 2004 09:03:38 -0400 by phpDocumentor 1.3.0RC3