Class SecureRandom
Library for normalizing bytes returned by secure random byte generators.
SecureRandom takes bytes generated by secure random byte generators and
normalizes (i.e. provides even distribution) for other common usages, such
as generation of integers, floats and randomizing arrays.
Methods summary
public

#
__construct( Riimu\Kit\SecureRandom\Generator\Generator $generator = null )
Creates a new instance of SecureRandom.
Creates a new instance of SecureRandom.
You can either provide a generator to use for generating random bytes or
give null as the argument to use default generators. If null is provided,
the constructor will attempt to create the random byte generators in the
following order until it finds one that is supported:
 Internal
 RandomReader
 Mcrypt
 OpenSSL
Note that since most cases require nonblocking random generation, the
default generators use /dev/urandom as the random source. If you do not
think this provides enough security, create the desired random generator
using /dev/random as the source.
Parameters
 $generator
 Random byte generator or null for default
Throws

public
string

#
getBytes( integer $count )
Returns a number of random bytes.
Returns a number of random bytes.
Parameters
 $count
 Number of random bytes to return
Returns
string Randomly generated bytes
Throws

public
integer

#
getInteger( integer $min, integer $max )
Returns a random integer between two positive integers (inclusive).
Returns a random integer between two positive integers (inclusive).
Parameters
 $min
 Minimum limit
 $max
 Maximum limit
Returns
integer Random integer between minimum and maximum limit
Throws

public
float

#
getFloat( )
Returns a random float between 0 and 1 (inclusive).
Returns a random float between 0 and 1 (inclusive).
Returns
float Random float between 0 and 1

public
array

#
getArray( array $array, integer $count )
Returns a number of randomly selected elements from the array.
Returns a number of randomly selected elements from the array.
This method returns randomly selected elements from the array. The number
of elements is determined by by the second argument. The elements are
returned in random order but the keys are preserved.
Parameters
 $array
 Array of elements
 $count
 Number of elements to return from the array
Returns
array Randomly selected elements in random order
Throws

public
mixed

#
choose( array $array )
Returns one randomly selected value from the array.
Returns one randomly selected value from the array.
Parameters
 $array
 Array to choose from
Returns
mixed One randomly selected value from the array
Throws

public
array

#
shuffle( array $array )
Returns the array with the elements reordered in random order.
Returns the array with the elements reordered in random order.
Parameters
Returns
array The provided array with elements in random order

public
arraystring

#
getSequence( stringarray $choices, integer $length )
Returns a random sequence of values.
Returns a random sequence of values.
If a string is provided as the first argument, the method returns a
string with characters selected from the provided string. The length of
the returned string is determined by the second argument.
If an array is provided as the first argument, the method returns an
array with elements selected from the provided array. The size of the
returned array is determined by the second argument.
The functionality is similar to getArray(), except for the fact that the
returned value can contain the same character or element multiple times.
If the same character or element appears multiple times in the provided
argument, it will increase the relative chance of it appearing in the
returned value.
Parameters
 $choices
 Values to choose from
 $length
 Length of the sequence
Returns
arraystring The generated random sequence
Throws
