public class ISAACRandomGenerator extends java.lang.Object implements RandomGenerator
Modifier and Type | Field and Description |
---|---|
private ISAACEngine |
engine |
private byte[] |
seed |
Constructor and Description |
---|
ISAACRandomGenerator()
Default constructor, at the moment does nothing
|
Modifier and Type | Method and Description |
---|---|
void |
addSeedMaterial(byte[] seed)
Add more seed material to the generator.
|
void |
addSeedMaterial(long seed)
Add more seed material to the generator.
|
void |
init(StreamCipher engine,
byte[] seed)
Initialize the ISAAC random generator with an initial seed value.
|
java.math.BigInteger |
nextBigInteger()
Since most PRNG are used for NUMBERS it seems prudent to add an additional
function to return randomly generated data as BigInteger instead of having to
always convert manually from bytes.
|
void |
nextBytes(byte[] bytes)
Generates a random data using ISAAC stream cipher and populates
the byte array provided with the random number.
|
void |
nextBytes(byte[] bytes,
int start,
int len)
Generates a random data using ISAAC stream cipher and populates
the byte array provided with the random number.
|
int |
nextInt()
Since most PRNG are used for NUMBERS it seems prudent to add an additional
function to return randomly generated data as int instead of having to
always convert manually from bytes.
|
private ISAACEngine engine
private byte[] seed
public ISAACRandomGenerator()
public void init(StreamCipher engine, byte[] seed) throws DataLengthException, java.lang.IllegalArgumentException
engine
- The ISAAC engine, currently ISAAC+ is NOT supportedseed
- The seed value, must be specifiedjava.lang.IllegalArgumentException
- if the stream cipher is not ISAACDataLengthException
- if the seed is not specified or has weak entropypublic void addSeedMaterial(byte[] seed) throws DataLengthException
RandomGenerator
addSeedMaterial
in interface RandomGenerator
seed
- a byte array to be mixed into the generator's state.DataLengthException
public void addSeedMaterial(long seed) throws DataLengthException
RandomGenerator
addSeedMaterial
in interface RandomGenerator
seed
- a long value to be mixed into the generator's state.DataLengthException
public void nextBytes(byte[] bytes)
nextBytes
in interface RandomGenerator
bytes
- The output byte array to populate with the random numberpublic void nextBytes(byte[] bytes, int start, int len)
nextBytes
in interface RandomGenerator
bytes
- The output byte array to populate with the random numberstart
- The index to start filling atlen
- The length of the segment to fillpublic java.math.BigInteger nextBigInteger()
public int nextInt()