Here you can find the source of randomBytes(int size)
Parameter | Description |
---|---|
size | - number of bytes to return |
public static byte[] randomBytes(int size)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { /**/*www .j a v a2s. co m*/ * Returns a random byte array. Note: Does not use a secure random number * generator. * * @param size * - number of bytes to return * @return random byte array * * @see {@link SecureRandom} */ public static byte[] randomBytes(int size) { byte[] saltBytes = new byte[size]; new Random().nextBytes(saltBytes); return saltBytes; } }