TrueZIP 6.8.3

de.schlichtherle.crypto.generators
Class DigestRandom

java.lang.Object
  extended by java.util.Random
      extended by de.schlichtherle.crypto.generators.DigestRandom
All Implemented Interfaces:
Serializable

public class DigestRandom
extends Random

A Pseudo Random Number Generator (PRNG) using an arbitrary digest function. Similar to SecureRandom, this class is self-seeding. However, unlike SecureRandom, it's not seedable: Calling one of the Random.setSeed(long) methods does not have any effect!

Unlike its super class, this class does not support serialization.

Author:
Christian Schlichtherle
See Also:
Serialized Form

Field Summary
private  long counter
           
private  Digest digest
           
private  byte[] in
           
private  byte[] out
           
private  int outOff
           
private static SecureRandom seeder
           
 
Constructor Summary
DigestRandom(Digest digest)
           
 
Method Summary
protected  int next(int numBits)
          Generates an integer containing the user-specified number of pseudo-random bits (right justified, with leading zeros).
 void nextBytes(byte[] bytes)
          Generates a user-specified number of pseudo random bytes.
private  void update()
           
 
Methods inherited from class java.util.Random
nextBoolean, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

seeder

private static final SecureRandom seeder

in

private final byte[] in

counter

private long counter

digest

private final Digest digest

out

private final byte[] out

outOff

private int outOff
Constructor Detail

DigestRandom

public DigestRandom(Digest digest)
Method Detail

nextBytes

public void nextBytes(byte[] bytes)
Generates a user-specified number of pseudo random bytes. This method is used as the basis of all random entities returned by this class (except seed bytes).

Overrides:
nextBytes in class Random
Parameters:
bytes - The array to be filled in with random bytes.

next

protected final int next(int numBits)
Generates an integer containing the user-specified number of pseudo-random bits (right justified, with leading zeros). This method overrides a java.util.Random method, and serves to provide a source of random bits to all of the methods inherited from that class (for example, nextInt, nextLong, and nextFloat).

Overrides:
next in class Random
Parameters:
numBits - Number of pseudo-random bits to be generated, where 0 <= numBits <= 32.
Returns:
An int containing the user-specified number of pseudo-random bits (right justified, with leading zeros).

update

private void update()

TrueZIP 6.8.3

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.