Java Snippet – Using SecureRandom

A better random number generator
[java]
import java.security.SecureRandom;

public static SecureRandom random = null;
static {
try {
random = SecureRandom.getInstance(“SHA1PRNG”);
random.setSeed( random.generateSeed(256) );
} catch( Exception e ) {
e.printStackTrace();
}
}
[/java]

Leave a Comment

Your email address will not be published.

Scroll to Top