de.schlichtherle.crypto.generators
Class DigestRandom
java.lang.Object
java.util.Random
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
|
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.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
DigestRandom
public DigestRandom(Digest digest)
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()
Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.