Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

fbRandom_DevRandom Class Reference

Inheritance diagram for fbRandom_DevRandom:

Inheritance graph
[legend]
List of all members.

Detailed Description

Blocking RNG for Unix/Linux based systems supporting /dev/random.

Definition at line 22 of file DevRandom.php.

Public Member Functions

 fbRandom_DevRandom ($seed=null)
 nextBase64String ($length=1)
 nextURL64String ($length=1)
 nextBase95String ($length=1)
 nextBoolean ()
 nextDouble ()
 nextGaussian ()
 nextInt ($min=null, $max=null)
 nextSalt ()
 nextPrintableString ($length=1)
 nextString ($length=1)
 nextBytes ($length=1)
 getSeed ()
 setSeed ($seed=null)
 getRandomSeed ()
 setRandomSeed ()

Static Public Member Functions

 isAvailable ()
 isBlocking ()
 _getRandomByte ($modulo=0)
 _getRandomString ($length)
 isSeedable ()
getInstance ($blocking=null, $seed=null)
 getEntropy ()

Public Attributes

 $_file = '/dev/random'
 $_fp = null


Constructor & Destructor Documentation

fbRandom_DevRandom::fbRandom_DevRandom seed = null  ) 
 

Constructor

Definition at line 34 of file DevRandom.php.


Member Function Documentation

fbRandom_DevRandom::_getRandomByte modulo = 0  )  [static]
 

Parameters:
$modulo int 0 thru 255
Returns:
int 0 to 255

Reimplemented from fbRandom.

Definition at line 86 of file DevRandom.php.

fbRandom_DevRandom::_getRandomString length  )  [static]
 

Parameters:
$length int length of string
Returns:
string String of random characters of length $length

Reimplemented from fbRandom.

Definition at line 114 of file DevRandom.php.

fbRandom::getEntropy  )  [static, inherited]
 

Return a string of entropy

Returns:
string

Todo:
would implode('~', ...) be quicker?

Definition at line 114 of file Random.php.

& fbRandom::getInstance blocking = null,
seed = null
[static, inherited]
 

Definition at line 58 of file Random.php.

References fbRandom_DevUrandom::isAvailable(), isAvailable(), isAvailable(), and fbRandom::setSeed().

Referenced by fbHMAC_Login::_getChallenge().

fbRandom::getRandomSeed  )  [inherited]
 

Returns:
int a new random seed

Definition at line 526 of file Random.php.

Referenced by fbRandom_Rand::setSeed(), and fbRandom_MT_Rand::setSeed().

fbRandom::getSeed  )  [inherited]
 

Returns:
int the last seed passed to setSeed(), otherwise null

Definition at line 511 of file Random.php.

References fbRandom::$_seed.

fbRandom_DevRandom::isAvailable  )  [static]
 

Returns:
bool

Reimplemented from fbRandom.

Reimplemented in fbRandom_DevUrandom.

Definition at line 51 of file DevRandom.php.

Referenced by fbRandom::getInstance().

fbRandom_DevRandom::isBlocking  )  [static]
 

Return if this random class blocks or not

Returns:
bool true if this random class blocks, otherwise false

Reimplemented from fbRandom.

Definition at line 77 of file DevRandom.php.

fbRandom::isSeedable  )  [static, inherited]
 

Return if this random class is seedable or not

Returns:
bool true if this random class is seedable, otherwise false

Reimplemented in fbRandom_MT_Rand, and fbRandom_Rand.

Definition at line 51 of file Random.php.

fbRandom::nextBase64String length = 1  )  [inherited]
 

Parameters:
$length int
Returns:
string

Definition at line 188 of file Random.php.

References fbRandom::_getRandomString().

fbRandom::nextBase95String length = 1  )  [inherited]
 

Parameters:
$length int
Returns:
string

Definition at line 234 of file Random.php.

fbRandom::nextBoolean  )  [inherited]
 

Returns:
bool

Definition at line 249 of file Random.php.

References fbRandom::_getRandomByte().

fbRandom::nextBytes length = 1  )  [inherited]
 

Parameters:
$length int
Returns:
string a random string of length $length with ASCII NULs (0x00)

Definition at line 497 of file Random.php.

References fbRandom::_getRandomString().

fbRandom::nextDouble  )  [inherited]
 

Returns:
double >= 0.0 and < 1.0

Reimplemented in fbRandom_LCG.

Definition at line 256 of file Random.php.

References fbRandom::_getRandomString().

Referenced by fbRandom::nextGaussian().

fbRandom::nextGaussian  )  [inherited]
 

See also:
http://www.taygeta.com/random/gaussian.html
Returns:
double

Definition at line 310 of file Random.php.

References fbRandom::nextDouble().

fbRandom::nextInt min = null,
max = null
[inherited]
 

Parameters:
$min int
$max int
Returns:
int

Definition at line 338 of file Random.php.

References fbRandom::_getRandomByte(), fbRandom::_getRandomString(), and fbRandom::nextInt().

Referenced by fbRandom::nextInt().

fbRandom::nextPrintableString length = 1  )  [inherited]
 

Todo:
should the characters 128-159 be considered "printable"?
32-126, 160-255, 95 + 96 characters = 191 + 33 = 224 + 32 = 256

Parameters:
$length int
Returns:
string

Definition at line 457 of file Random.php.

References fbRandom::_getRandomByte().

fbRandom::nextSalt  )  [inherited]
 

Returns:
string

Definition at line 440 of file Random.php.

References fbRandom::_getRandomByte().

fbRandom::nextString length = 1  )  [inherited]
 

Parameters:
$length int
Returns:
string a random string of length $length without ASCII NULs (0x00)

Definition at line 481 of file Random.php.

fbRandom::nextURL64String length = 1  )  [inherited]
 

URL compatible Base64 encoding

This is how PHP encodes the session hash when session.hash_bits_per_character is set to '6' in php.ini

Parameters:
$length int
Returns:
string

Definition at line 214 of file Random.php.

References fbRandom::_getRandomString().

fbRandom::setRandomSeed  )  [inherited]
 

Returns:
bool true if this RNG is seedable, otherwise false

Definition at line 533 of file Random.php.

References fbRandom::setSeed().

fbRandom::setSeed seed = null  )  [inherited]
 

Parameters:
$seed mixed an integer of the new seed, or null to generate a new random seed
Returns:
bool true if this RNG is seedable, otherwise false

Reimplemented in fbRandom_MT_Rand, and fbRandom_Rand.

Definition at line 519 of file Random.php.

Referenced by fbRandom::getInstance(), and fbRandom::setRandomSeed().


Member Data Documentation

fbRandom_DevRandom::$_file = '/dev/random'
 

Reimplemented in fbRandom_DevUrandom.

Definition at line 25 of file DevRandom.php.

fbRandom_DevRandom::$_fp = null
 

Definition at line 29 of file DevRandom.php.


The documentation for this class was generated from the following file:
Generated on Fri Mar 19 12:52:33 2004 for Freebeer by doxygen 1.3.6-20040222