/** * Returns the SecureRandom used to generate secure random data. * * <p>Creates and initializes if null. Uses {@code System.currentTimeMillis() + * System.identityHashCode(this)} as the default seed. * * @return the SecureRandom used to generate secure random data, wrapped in a {@link * RandomGenerator}. */ private RandomGenerator getSecRan() { if (secRand == null) { secRand = RandomGeneratorFactory.createRandomGenerator(new SecureRandom()); secRand.setSeed(System.currentTimeMillis() + System.identityHashCode(this)); } return secRand; }
/** * Reseeds the random number generator with {@code System.currentTimeMillis() + * System.identityHashCode(this))}. */ public void reSeed() { getRandomGenerator().setSeed(System.currentTimeMillis() + System.identityHashCode(this)); }
/** * Sets the default generator to a {@link Well19937c} generator seeded with {@code * System.currentTimeMillis() + System.identityHashCode(this))}. */ private void initRan() { rand = new Well19937c(System.currentTimeMillis() + System.identityHashCode(this)); }
/** * Reseeds the secure random number generator with the current time in milliseconds. * * <p>Will create and initialize if null. */ public void reSeedSecure() { getSecRan().setSeed(System.currentTimeMillis()); }