Example usage for java.security SecureRandom getProvider

List of usage examples for java.security SecureRandom getProvider

Introduction

In this page you can find the example usage for java.security SecureRandom getProvider.

Prototype

public final Provider getProvider() 

Source Link

Document

Returns the provider of this SecureRandom object.

Usage

From source file:Main.java

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);//  w  w w .  java 2 s.  c o m
    System.out.println(bytes);
}

From source file:Main.java

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();

    SecureRandom newRandom = SecureRandom.getInstance("SHA1PRNG", provider);

    System.out.println(provider.getName());

    byte[] bytes = new byte[numBytes];
    srand.nextBytes(bytes);//  w ww  . ja  va 2  s . c om
    System.out.println(bytes);
}