Java Snippet – Using SecureRandom

A better random number generator

JAVA:
  1. import java.security.SecureRandom;
  2.  
  3. ...
  4.  
  5. public static SecureRandom random = null;
  6.  
  7. static {
  8.     try {
  9.         random = SecureRandom.getInstance("SHA1PRNG");
  10.         random.setSeed( random.generateSeed(256) );
  11.     } catch( Exception e ) {
  12.         e.printStackTrace();
  13.     }
  14. }

No Comments so far
Leave a comment



Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required, but not displayed publically)