Class PureSpinner

All Implemented Interfaces:

public class PureSpinner
extends java.util.Random

This class uses the scheduler to gather entropy.

To generate one byte of data it launches a thread which counts in a tight loop. After a certain time, this thread is killed and the 8 lowest order bytes of the counter are returned.

The spin-period is set when a PureSpinner object is created. It is chosen so that the counter will reach at least 1024 when a byte is generated. However, under excessive load the counter may not count much above 256.

The output of this RNG is may not have very good statistical properties, but each byte of data should contain one or two bits of entropy. It should not be used directly, but rather to gather entropy for another PRNG class such as the RandomSpinner class.

The helper class which does the actual number generation is based on code by Henry Strickland ( and Greg Noel ( This was in turn based on similar C code by Matt Blaze, Jack Lacy, and Don Mitchell.

Logi Ragnarsson (
See Also:
RandomMD5, Spinner, Serialized Form

Constructor Summary
Method Summary
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public PureSpinner()
Method Detail


public void nextBytes(byte[] bytes)
Generates a user specified number of random bytes.
nextBytes in class java.util.Random

Copyright 1997-2000 Logi Ragnarsson