Math_Random
[ class tree: Math_Random ] [ index: Math_Random ] [ all elements ]

Class: Math_Random_Stream

Source Location: /Math/Random/Stream.php

Class Overview

Math_Random
   |
   --Math_Random_Stream

Random number source using an entropy file or device


Author(s):

Copyright:

  • 2005 Ants Aasma

Variables

Methods


Inherited Methods

Class: Math_Random

Math_Random::getFloat()
Return a random float
Math_Random::getInteger()
Return a random integer
Math_Random::getMaxInteger()
Return maximum supported integer
Math_Random::getMinInteger()
Return minimum supported integer
Math_Random::getString()
Get a string of random characters

Class Details

[line 61]
Random number source using an entropy file or device

Returns random numbers from an entropy file or device or any PHP stream.

Primary use on *nix platforms is to use the /dev/random and /dev/urandom entropy sources. Be aware that the once the kernels entropy pool (defaults to 4096 bits) is depleted the /dev/random device blocks until sufficient entropy is available and /dev/urandom returns pseudorandom data. The generation of entropy is really slow, espescially on an idle system. (3 bytes per second is quite realistic)




Tags:

license:  BSD License (3 Clause)
copyright:  2005 Ants Aasma
author:  Ants Aasma <ants.aasma@gmail.com>


[ Top ]


Class Variables

$stream =

[line 63]



Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 73]

Math_Random_Stream __construct( [string $stream = '/dev/random'])

Constructor



Tags:

throws:  Math_Random_FileException when stream isn't readable or can't be opened


Parameters:

string   $stream   stream to read random data from

[ Top ]

method getInteger [line 134]

int getInteger( int $min, int $max)

Return a random integer

Returns a random integer between $min and $max (inclusive).




Tags:

return:  Random integer


Overrides Math_Random::getInteger() (Return a random integer)

Parameters:

int   $min   minimum value of the random number
int   $max   maximum value of the random number

[ Top ]

method getMaxInteger [line 120]

int getMaxInteger( )

Return maximum supported integer

The value returned by this function is the upper limit to the getInteger method parameters. Values above this are not supported by the used class and will most likely not work.




Tags:

return:  Minimum supported integer


Overrides Math_Random::getMaxInteger() (Return maximum supported integer)

[ Top ]

method getMinInteger [line 106]

int getMinInteger( )

Return minimum supported integer

The value returned by this function is the lower limit to the getInteger method parameters. Values below this are not supported by the used class and will most likely not work.




Tags:

return:  Minimum supported integer


Overrides Math_Random::getMinInteger() (Return minimum supported integer)

[ Top ]

method getString [line 92]

string getString( int $len)

Get a string of random characters

Returns a binary string of 8bit characters with the specified length.




Tags:

return:  string of random characters


Overrides Math_Random::getString() (Get a string of random characters)

Parameters:

int   $len   Length of string to return

[ Top ]


Documentation generated on Sun, 09 Oct 2005 06:53:25 +0300 by phpDocumentor 1.3.0RC3