public class DigestRandomGenerator extends java.lang.Object implements RandomGenerator
Internal access to the digest is synchronized so a single one of these can be shared.
Modifier and Type | Field and Description |
---|---|
private static long |
CYCLE_COUNT |
private Digest |
digest |
private byte[] |
seed |
private long |
seedCounter |
private byte[] |
state |
private long |
stateCounter |
Constructor and Description |
---|
DigestRandomGenerator(Digest digest) |
Modifier and Type | Method and Description |
---|---|
void |
addSeedMaterial(byte[] inSeed)
Add more seed material to the generator.
|
void |
addSeedMaterial(long rSeed)
Add more seed material to the generator.
|
private void |
cycleSeed() |
private void |
digestAddCounter(long seed) |
private void |
digestDoFinal(byte[] result) |
private void |
digestUpdate(byte[] inSeed) |
private void |
generateState() |
void |
nextBytes(byte[] bytes)
Fill bytes with random values.
|
void |
nextBytes(byte[] bytes,
int start,
int len)
Fill part of bytes with random values.
|
private static long CYCLE_COUNT
private long stateCounter
private long seedCounter
private Digest digest
private byte[] state
private byte[] seed
public DigestRandomGenerator(Digest digest)
public void addSeedMaterial(byte[] inSeed)
RandomGenerator
addSeedMaterial
in interface RandomGenerator
inSeed
- a byte array to be mixed into the generator's state.public void addSeedMaterial(long rSeed)
RandomGenerator
addSeedMaterial
in interface RandomGenerator
rSeed
- a long value to be mixed into the generator's state.public void nextBytes(byte[] bytes)
RandomGenerator
nextBytes
in interface RandomGenerator
bytes
- byte array to be filled.public void nextBytes(byte[] bytes, int start, int len)
RandomGenerator
nextBytes
in interface RandomGenerator
bytes
- byte array to be filled.start
- index to start filling at.len
- length of segment to fill.private void cycleSeed()
private void generateState()
private void digestAddCounter(long seed)
private void digestUpdate(byte[] inSeed)
private void digestDoFinal(byte[] result)