static {
String egd = System.getProperty( "java.security.egd" );
if ( egd == null ) {
String os = System.getProperty( "os.name" ).toLowerCase();
if ( os.indexOf( "linux" ) > -1 || os.indexOf( "mac" ) > -1 ) {
System.setProperty( "java.security.egd", "file:/./dev/urandom" );
}
}
}
public static Random initRandom() {
try {
// OS is Linux and JDK version >= 1.8,
// non-blocking PRNG algorithm with /dev/urandom
return SecureRandom.getInstance( "NativePRNGNonBlocking" );
}
catch (NoSuchAlgorithmException e) {
// OS is not Linux or JDK version < 1.8
return new SecureRandom();
}
}