Java Utililty Methods Random Byte Array

List of utility methods to do Random Byte Array

Description

The list of methods to do Random Byte Array are organized into topic(s).

Method

byte[]randomBytes(int size)
Returns a random byte array.
byte[] saltBytes = new byte[size];
new Random().nextBytes(saltBytes);
return saltBytes;
byte[]randomBytes(long seed, int blockCount, int blockSize)
random Bytes
return randomBytes(seed, blockCount * blockSize);
byte[]randomBytes(Random r, int length)
For those that like the random bytes to be created and returned.
byte[] ret = new byte[length];
r.nextBytes(ret);
return ret;
byte[]randomBytes(Random rand, int size)
random Bytes
byte[] bytes = new byte[size];
rand.nextBytes(bytes);
return bytes;
voidrandomBytesSlowNextInt(Random r, byte[] buf, int from, int len)
Fill specified range of byte array with random data.
if (from == 0 && len == buf.length) {
    r.nextBytes(buf);
    return;
byte[] tmp = new byte[len];
r.nextBytes(tmp);
System.arraycopy(tmp, 0, buf, from, len);
byte[]randomBytesWithEveryPossibleByteValueRepresentedAtLeastOnce()
random Bytes With Every Possible Byte Value Represented At Least Once
Random r = new Random();
byte[] data = new byte[1024 * 1024 * 10];
r.nextBytes(data);
byte next = Byte.MIN_VALUE;
int numByteValuesPossible = (-Byte.MIN_VALUE) + Byte.MAX_VALUE;
for (int x = 0; x < numByteValuesPossible; x++) {
    data[x] = next;
    next++;
...