Java API Tutorial - Java SecureRandom.generateSeed(int numBytes)








Syntax

SecureRandom.generateSeed(int numBytes) has the following syntax.

public byte[] generateSeed(int numBytes)

Example

In the following code shows how to use SecureRandom.generateSeed(int numBytes) method.

//from  w w w  . j  ava 2s . c  o m
import java.security.SecureRandom;
import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {
    SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");

    System.out.println(Arrays.toString(sr.generateSeed(8)));
  }
}

The code above generates the following result.