Java Random Byte Array randomByte(byte[] b)

Here you can find the source of randomByte(byte[] b)

Description

random Byte

License

Open Source License

Declaration

private static byte randomByte(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    private static final long multiplier = 0x5DEECE66DL;
    private static final long addend = 0xBL;
    private static final long mask = (1L << 48) - 1;
    private static final long integerMask = (1L << 33) - 1;
    private static long seed;

    private static byte randomByte(byte[] b) {
        int ran = (int) ((next() & integerMask) >>> 16);
        return b[ran % b.length];
    }/*from w  w  w .  j a va2s .  c  o m*/

    private static long next() {
        long oldSeed = seed;
        long nextSeed = 0L;
        do {
            nextSeed = (oldSeed * multiplier + addend) & mask;
        } while (oldSeed == nextSeed);
        seed = nextSeed;
        return nextSeed;
    }
}

Related

  1. getRandomBytes(int size)
  2. nextBytes(byte[] bytes)
  3. nextBytes(int count)
  4. nextBytes(int length)
  5. randBytes(int length)
  6. randomByteArray(int length)
  7. randomBytes()
  8. randomBytes(byte[] bytes)
  9. randomBytes(final int numBytes)