RandomSource random = randomSource != null ? randomSource : new Yarrow();
Yarrow r = new Yarrow(new File("/dev/urandom"), "SHA1", "Rijndael", true, false);
public void testNextBoolean() { Yarrow y = new Yarrow(SEED_FILE, "SHA1", "Rijndael", false, false, false); int[] results = new int[2]; int RUNS = 1000000; for(int i=0; i<RUNS; i++) { if(y.nextBoolean()) results[0]++; else results[1]++; } assertEquals(RUNS, results[0]+results[1]); assertTrue(results[0] > RUNS/2 - RUNS/1000); assertTrue(results[1] > RUNS/2 - RUNS/1000); } }
public void testDouble() { Yarrow y = new Yarrow(SEED_FILE, "SHA1", "Rijndael", false, false, false); ScalarSampleStatistics sample = new ScalarSampleStatistics(); for(int i = 0; i < 10000; ++i) { sample.add(y.nextDouble()); } assertEquals(0.5, sample.getMean(), 0.02); assertEquals(1.0 / (2.0 * Math.sqrt(3.0)), sample.getStandardDeviation(), 0.002); }
entropyGatheringThread.start(); this.random = new Yarrow(seed);