/** * Generates random bytes and places them into a user-supplied array. * * <p> * The array is filled with bytes extracted from random integers. * This implies that the number of random bytes generated may be larger than * the length of the byte array. * </p> * * @param bytes Array in which to put the generated bytes. Cannot be {@code null}. */ public void nextBytes(byte[] bytes) { nextBytesFill(bytes, 0, bytes.length); }
/** * Generates random bytes and places them into a user-supplied array. * * <p> * The array is filled with bytes extracted from random integers. * This implies that the number of random bytes generated may be larger than * the length of the byte array. * </p> * * @param bytes Array in which to put the generated bytes. Cannot be {@code null}. * @param start Index at which to start inserting the generated bytes. * @param len Number of bytes to insert. * @throws OutOfRangeException if {@code start < 0} or {@code start >= bytes.length}. * @throws OutOfRangeException if {@code len < 0} or {@code len > bytes.length - start}. */ public void nextBytes(byte[] bytes, int start, int len) { if (start < 0 || start >= bytes.length) { throw new OutOfRangeException(start, 0, bytes.length); } if (len < 0 || len > bytes.length - start) { throw new OutOfRangeException(len, 0, bytes.length - start); } nextBytesFill(bytes, start, len); }
/** * Generates random bytes and places them into a user-supplied array. * * <p> * The array is filled with bytes extracted from random integers. * This implies that the number of random bytes generated may be larger than * the length of the byte array. * </p> * * @param bytes Array in which to put the generated bytes. Cannot be {@code null}. */ public void nextBytes(byte[] bytes) { nextBytesFill(bytes, 0, bytes.length); }
/** * Generates random bytes and places them into a user-supplied array. * * <p> * The array is filled with bytes extracted from random integers. * This implies that the number of random bytes generated may be larger than * the length of the byte array. * </p> * * @param bytes Array in which to put the generated bytes. Cannot be {@code null}. */ public void nextBytes(byte[] bytes) { nextBytesFill(bytes, 0, bytes.length); }
/** * Generates random bytes and places them into a user-supplied array. * * <p> * The array is filled with bytes extracted from random integers. * This implies that the number of random bytes generated may be larger than * the length of the byte array. * </p> * * @param bytes Array in which to put the generated bytes. Cannot be {@code null}. * @param start Index at which to start inserting the generated bytes. * @param len Number of bytes to insert. * @throws OutOfRangeException if {@code start < 0} or {@code start >= bytes.length}. * @throws OutOfRangeException if {@code len < 0} or {@code len > bytes.length - start}. */ public void nextBytes(byte[] bytes, int start, int len) { if (start < 0 || start >= bytes.length) { throw new OutOfRangeException(start, 0, bytes.length); } if (len < 0 || len > bytes.length - start) { throw new OutOfRangeException(len, 0, bytes.length - start); } nextBytesFill(bytes, start, len); }
/** * Generates random bytes and places them into a user-supplied array. * * <p> * The array is filled with bytes extracted from random integers. * This implies that the number of random bytes generated may be larger than * the length of the byte array. * </p> * * @param bytes Array in which to put the generated bytes. Cannot be {@code null}. * @param start Index at which to start inserting the generated bytes. * @param len Number of bytes to insert. * @throws OutOfRangeException if {@code start < 0} or {@code start >= bytes.length}. * @throws OutOfRangeException if {@code len < 0} or {@code len > bytes.length - start}. */ public void nextBytes(byte[] bytes, int start, int len) { if (start < 0 || start >= bytes.length) { throw new OutOfRangeException(start, 0, bytes.length); } if (len < 0 || len > bytes.length - start) { throw new OutOfRangeException(len, 0, bytes.length - start); } nextBytesFill(bytes, start, len); }