Java SecureRandom.setSeed(long seed)

Syntax

SecureRandom.setSeed(long seed) has the following syntax.

public void setSeed(long seed)

Example

In the following code shows how to use SecureRandom.setSeed(long seed) method.


// w  w w  .ja  v  a2  s . co m
import java.security.SecureRandom;

public class Main {
  public static void main(String args[]) throws Exception {
    SecureRandom ran = SecureRandom.getInstance("SHA1PRNG", "SUN");
    ran.setSeed(101L);
    ran.setSeed(101L);
    byte[] seeds = ran.getSeed(24);
    for (int i = 0; i < seeds.length; i++) {
      System.out.println("Seed[" + i + "]:" + seeds[i]);
    }
  }
}
   




















Home »
  Java Tutorial »
    java.security »




SecureRandom