Java SecureRandom.getProvider()

Syntax

SecureRandom.getProvider() has the following syntax.

public final Provider getProvider()

Example

In the following code shows how to use SecureRandom.getProvider() method.


/*w  w w. j  a v  a 2s. c o m*/

import java.security.NoSuchAlgorithmException;
import java.security.Provider;
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});

    Provider provider = srand.getProvider();
    System.out.println(provider.getName());
    
    byte[] bytes = new byte[numBytes];
    srand.nextBytes(bytes);
    System.out.println(bytes);
  }
}




















Home »
  Java Tutorial »
    java.security »




SecureRandom