Java SecureRandom .getInstance (String algorithm, String provider)

Syntax

SecureRandom.getInstance(String algorithm, String provider) has the following syntax.

public static SecureRandom getInstance(String algorithm,    String provider)    throws NoSuchAlgorithmException ,      NoSuchProviderException

Example

In the following code shows how to use SecureRandom.getInstance(String algorithm, String provider) method.


import java.security.SecureRandom;
/*from   w  w w  .j a v a  2s .  c  om*/
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