Java SecureRandom(byte[] seed) Constructor
Syntax
SecureRandom(byte[] seed) constructor from SecureRandom has the following syntax.
public SecureRandom(byte[] seed)
Example
In the following code shows how to use SecureRandom.SecureRandom(byte[] seed) constructor.
/* w ww . j av a 2s.c o m*/
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class Main {
public static void main(String[] args) throws NoSuchAlgorithmException {
int numBytes = (new Integer("1111")).intValue();
SecureRandom srand = new SecureRandom(new byte[]{1,2,3,4});
byte[] bytes = new byte[numBytes];
srand.nextBytes(bytes);
System.out.println(new String(bytes));
}
}