|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Random
org.logi.crypto.random.RandomFromStream
This class reads bits from an InputStream object and returns them as random values. No randomness checking is done and an Error is thrown if the end of the Reader is ever reached.
This class is useful f.ex. for reding random bits from the
/dev/random
or /dev/urandom
devices
where they are available (such as in linux). This would be done with
the following code:
Random rand; try { rand=new RandomFromReader(new FileInputStream("/dev/random")); } catch (FileNotFoundException e) { rand=new RandomSpinner(); }
Constructor Summary | |
RandomFromStream(java.io.InputStream in)
Create a new RandomFromStream obejct. |
Method Summary | |
protected int |
next(int bits)
Generates the next random number. |
void |
nextBytes(byte[] bytes)
Generates a user specified number of random bytes. |
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 |
Constructor Detail |
public RandomFromStream(java.io.InputStream in)
in
Method Detail |
public void nextBytes(byte[] bytes)
protected int next(int bits)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |