/** * Generates random bytes and places them into a user-supplied * byte array. The number of random bytes produced is equal to * the length of the byte array. * * @param bytes the non-null byte array in which to put the * random bytes */ @Override public void nextBytes(byte[] bytes) { randomGenerator.nextBytes(bytes); }
@Override public void nextBytes(byte[] bytes) { random.nextBytes(bytes); }
/** * {@inheritDoc} */ public synchronized void nextBytes(byte[] bytes) { wrapped.nextBytes(bytes); }
@Override public void nextBytes(byte[] bytes) { getRandomGenerator().nextBytes(bytes); }
/** * Returns a pseudorandom, uniformly distributed {@code long} value * between 0 (inclusive) and the specified value (exclusive), drawn from * this random number generator's sequence. * * @param rng random generator to use * @param n the bound on the random number to be returned. Must be * positive. * @return a pseudorandom, uniformly distributed {@code long} * value between 0 (inclusive) and n (exclusive). * @throws IllegalArgumentException if n is not positive. */ private static long nextLong(final RandomGenerator rng, final long n) throws IllegalArgumentException { if (n > 0) { final byte[] byteArray = new byte[8]; long bits; long val; do { rng.nextBytes(byteArray); bits = 0; for (final byte b : byteArray) { bits = (bits << 8) | (((long) b) & 0xffL); } bits &= 0x7fffffffffffffffL; val = bits % n; } while (bits - val + (n - 1) < 0); return val; } throw new NotStrictlyPositiveException(n); }
ran.nextBytes(randomBytes);
for (int iter = 1; iter < numIter + 1; iter++) { byte[] randomBytes = new byte[40]; secRan.nextBytes(randomBytes); alg.update(randomBytes);
/** * {@inheritDoc} */ public synchronized void nextBytes(byte[] bytes) { wrapped.nextBytes(bytes); }
/** * Generates random bytes and places them into a user-supplied * byte array. The number of random bytes produced is equal to * the length of the byte array. * * @param bytes the non-null byte array in which to put the * random bytes */ @Override public void nextBytes(byte[] bytes) { randomGenerator.nextBytes(bytes); }
/** * Generates random bytes and places them into a user-supplied * byte array. The number of random bytes produced is equal to * the length of the byte array. * * @param bytes the non-null byte array in which to put the * random bytes */ @Override public void nextBytes(byte[] bytes) { randomGenerator.nextBytes(bytes); }
/** * {@inheritDoc} */ public synchronized void nextBytes(byte[] bytes) { wrapped.nextBytes(bytes); }
@Override public void nextBytes(byte[] bytes) { random.nextBytes(bytes); }
private static byte[] randomBits(int numBits, RandomGenerator rnd) { if (numBits < 0) throw new IllegalArgumentException("numBits must be non-negative"); int numBytes = (int) (((long) numBits + 7) / 8); // avoid overflow byte[] randomBits = new byte[numBytes]; // Generate random bytes and mask out any excess bits if (numBytes > 0) { rnd.nextBytes(randomBits); int excessBits = 8 * numBytes - numBits; randomBits[0] &= (1 << (8 - excessBits)) - 1; } return randomBits; }
@Override public void nextBytes(@Nullable byte[] bytes) { delegateRng.nextBytes(bytes); }
@Override public void nextBytes(byte[] bytes) { getRandomGenerator().nextBytes(bytes); }
/** * Returns a pseudorandom, uniformly distributed {@code long} value * between 0 (inclusive) and the specified value (exclusive), drawn from * this random number generator's sequence. * * @param rng random generator to use * @param n the bound on the random number to be returned. Must be * positive. * @return a pseudorandom, uniformly distributed {@code long} * value between 0 (inclusive) and n (exclusive). * @throws IllegalArgumentException if n is not positive. */ private static long nextLong(final RandomGenerator rng, final long n) throws IllegalArgumentException { if (n > 0) { final byte[] byteArray = new byte[8]; long bits; long val; do { rng.nextBytes(byteArray); bits = 0; for (final byte b : byteArray) { bits = (bits << 8) | (((long) b) & 0xffL); } bits &= 0x7fffffffffffffffL; val = bits % n; } while (bits - val + (n - 1) < 0); return val; } throw new NotStrictlyPositiveException(n); }
/** * Returns a pseudorandom, uniformly distributed {@code long} value * between 0 (inclusive) and the specified value (exclusive), drawn from * this random number generator's sequence. * * @param rng random generator to use * @param n the bound on the random number to be returned. Must be * positive. * @return a pseudorandom, uniformly distributed {@code long} * value between 0 (inclusive) and n (exclusive). * @throws IllegalArgumentException if n is not positive. */ private static long nextLong(final RandomGenerator rng, final long n) throws IllegalArgumentException { if (n > 0) { final byte[] byteArray = new byte[8]; long bits; long val; do { rng.nextBytes(byteArray); bits = 0; for (final byte b : byteArray) { bits = (bits << 8) | (((long) b) & 0xffL); } bits &= 0x7fffffffffffffffL; val = bits % n; } while (bits - val + (n - 1) < 0); return val; } throw new NotStrictlyPositiveException(n); }
ran.nextBytes(randomBytes);
ran.nextBytes(randomBytes);
rng.nextBytes(new byte[] {}); rng.nextDouble(); rng.nextFloat();