Generating random longs with uniform distribution inside a range java.

381 views Asked by At

I need to generate an unspecified number of longs that are cryptographically secure have a uniform distribution and are within a given range. Will this produce what I need:

    SecureRandom rand = new SecureRandom();
    LongStream l = rand.longs(streamsize, randomNumberOrigin, 
                              randomNumberBound);
    long[] rands = l.toArray();
    return rands;

Are there any other better methods?

0

There are 0 answers