private void doFill(byte buf[]) { //long start = System.currentTimeMillis(); if (pool0Count >= MIN_POOL_SIZE && System.currentTimeMillis() - lastReseed > 100) { reseedCount++; //byte[] seed = new byte[0]; for (int i = 0; i < NUM_POOLS; i++) { if (reseedCount % (1 << i) == 0) { generator.addRandomBytes(pools[i].digest()); } } lastReseed = System.currentTimeMillis(); } generator.nextBytes(buf); //long now = System.currentTimeMillis(); //long diff = now-lastRefill; //lastRefill = now; //long refillTime = now-start; //System.out.println("Refilling " + (++refillCount) + " after " + diff + " for the PRNG took " + refillTime); }
/** Unused, see AsyncFortunaStandalone */ public void fillBlock() { //long start = System.currentTimeMillis(); if (pool0Count >= MIN_POOL_SIZE && System.currentTimeMillis() - lastReseed > 100) { reseedCount++; //byte[] seed = new byte[0]; for (int i = 0; i < NUM_POOLS; i++) { if (reseedCount % (1 << i) == 0) { generator.addRandomBytes(pools[i].digest()); } } lastReseed = System.currentTimeMillis(); } generator.nextBytes(buffer); //long now = System.currentTimeMillis(); //long diff = now-lastRefill; //lastRefill = now; //long refillTime = now-start; //System.out.println("Refilling " + (++refillCount) + " after " + diff + " for the PRNG took " + refillTime); }
private void writeObject(ObjectOutputStream out) throws IOException { byte[] seed = new byte[SEED_FILE_SIZE]; generator.nextBytes(seed); out.write(seed); }
@Override public final byte nextByte() { byte[] b = new byte[1]; nextBytes(b, 0, 1); return b[0]; }