import java.security.SecureRandom;
import javax.swing.JOptionPane;
/*
 * TestSecureRandom.java
 *
 * Created on February 6, 2005, 3:16 PM
 */

/**
 *
 * @author kraynek
 */
public class TestSecureRandom {
    
    /** Creates a new instance of TestSecureRandom */
    public TestSecureRandom()  {
        // generate a seed
        byte[] seed = {2,3,37,111};
        
        // Seed the generator
        SecureRandom rnd = null;
        try{
            rnd = SecureRandom.getInstance("SHA1PRNG");
        }catch(java.security.NoSuchAlgorithmException e){};
        // Seed the generator
        rnd.setSeed(seed);
        
        SecureRandom rnd1 = null;
        try{
            rnd1 = SecureRandom.getInstance("SHA1PRNG");
        }catch(java.security.NoSuchAlgorithmException e){};
        // Seed the generator
        rnd1.setSeed(seed);
        
        SecureRandom rnd2 = new SecureRandom();
        System.out.println(rnd2.getAlgorithm());
        // Seed the generator
        rnd2.setSeed(seed);
        
        SecureRandom rnd3 = new SecureRandom();
        System.out.println(rnd2.getAlgorithm());
        // Seed the generator
        rnd3.setSeed(seed);
        
        // Generate random numbers
        String out = "";
        for( int i = 0; i < 20; i++ ) {
            out += rnd.nextInt(37) + " " + rnd1.nextInt(37) + " " + rnd2.nextInt(37) + " " + rnd3.nextInt(37) + "\n";
        }// end for
        JOptionPane.showMessageDialog(null,out);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new TestSecureRandom();
    }
    
}

