Secure Random: SHA1PRNG : Secure Random « Security « Java






Secure Random: SHA1PRNG

 
import java.security.SecureRandom;
import java.security.Security;

public class MainClass {
  public static void main(String args[]) throws Exception {
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    SecureRandom rng = SecureRandom.getInstance("SHA1PRNG");
    rng.setSeed(711);

    int numberToGenerate = 999;
    byte randNumbers[] = new byte[numberToGenerate];

    rng.nextBytes(randNumbers);
    for(int j=0; j<numberToGenerate; j++) {
        System.out.print(randNumbers[j] + " ");
    }

  }
}
           
         
  








SecureRandomSHA1PRNG.zip( 1,198 k)

Related examples in the same category

1.Generating a Secure Random Number
2.Generate Seed