org.clazzes.optional.sec
Class DigestRandomGenerator

java.lang.Object
  extended by org.clazzes.optional.sec.DigestRandomGenerator
All Implemented Interfaces:
RandomGenerator, SeededRandomGenerator

public class DigestRandomGenerator
extends java.lang.Object
implements SeededRandomGenerator

Random generation based on the digest with counter. Calling addSeedMaterial will always increase the entropy of the hash.

Internal access to the digest is synchronized so a single one of these can be shared.


Constructor Summary
DigestRandomGenerator(Digest digest)
           
 
Method Summary
 void addSeedMaterial(byte[] inSeed)
          Add more seed material to the generator.
 void addSeedMaterial(long rSeed)
          Add more seed material to the generator.
 void nextBytes(byte[] bytes)
          Fill bytes with random values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigestRandomGenerator

public DigestRandomGenerator(Digest digest)
Method Detail

addSeedMaterial

public void addSeedMaterial(byte[] inSeed)
Description copied from interface: SeededRandomGenerator
Add more seed material to the generator.

Specified by:
addSeedMaterial in interface SeededRandomGenerator
Parameters:
inSeed - a byte array to be mixed into the generator's state.

addSeedMaterial

public void addSeedMaterial(long rSeed)
Description copied from interface: SeededRandomGenerator
Add more seed material to the generator.

Specified by:
addSeedMaterial in interface SeededRandomGenerator
Parameters:
rSeed - a long value to be mixed into the generator's state.

nextBytes

public void nextBytes(byte[] bytes)
Description copied from interface: RandomGenerator
Fill bytes with random values.

Specified by:
nextBytes in interface RandomGenerator
Parameters:
bytes - byte array to be filled.


Copyright © 2010. All Rights Reserved.