net.i2p.util
Class RandomSource

java.lang.Object
  extended byjava.util.Random
      extended byjava.security.SecureRandom
          extended bynet.i2p.util.RandomSource
All Implemented Interfaces:
java.io.Serializable

public class RandomSource
extends java.security.SecureRandom

Singleton for whatever PRNG i2p uses.

Author:
jrandom
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.security.SecureRandom
 
Constructor Summary
RandomSource(I2PAppContext context)
           
 
Method Summary
static RandomSource getInstance()
           
 EntropyHarvester harvester()
           
 void nextBytes(byte[] bytes)
          synchronized for older versions of kaffe
 int nextInt(int n)
          According to the java docs (http://java.sun.com/j2se/1.4.1/docs/api/java/util/Random.html#nextInt(int)) nextInt(n) should return a number between 0 and n (including 0 and excluding n).
 long nextLong(long n)
          Like the modified nextInt, nextLong(n) returns a random number from 0 through n, including 0, excluding n.
 
Methods inherited from class java.security.SecureRandom
generateSeed, getInstance, getInstance, getInstance, getProvider, getSeed, next, setSeed, setSeed
 
Methods inherited from class java.util.Random
nextBoolean, nextDouble, nextFloat, nextGaussian, nextInt, nextLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomSource

public RandomSource(I2PAppContext context)
Method Detail

getInstance

public static RandomSource getInstance()

nextInt

public int nextInt(int n)
According to the java docs (http://java.sun.com/j2se/1.4.1/docs/api/java/util/Random.html#nextInt(int)) nextInt(n) should return a number between 0 and n (including 0 and excluding n). However, their pseudocode, as well as sun's, kaffe's, and classpath's implementation INCLUDES NEGATIVE VALUES. WTF. Ok, so we're going to have it return between 0 and n (including 0, excluding n), since thats what it has been used for.


nextLong

public long nextLong(long n)
Like the modified nextInt, nextLong(n) returns a random number from 0 through n, including 0, excluding n.


nextBytes

public void nextBytes(byte[] bytes)
synchronized for older versions of kaffe


harvester

public EntropyHarvester harvester()