## Select the source of seed data for SecureRandom. By default an# attempt is made to use the entropy gathering device specified by# the securerandom.source property. If an exception occurs when# accessing the URL then the traditional system/thread activity# algorithm is used.## On Solaris and Linux systems, if file:/dev/urandom is specified and it# exists, a special SecureRandom implementation is activated by default.# This "NativePRNG" reads random bytes directly from /dev/urandom.## On Windows systems, the URLs file:/dev/random and file:/dev/urandom# enables use of the Microsoft CryptoAPI seed functionality.#securerandom.source=file:/dev/urandom
import java.security.SecureRandom;
class JRand {
public static void main(String args[]) throws Exception {
System.out.println("Ok: " +
SecureRandom.getInstance("SHA1PRNG").nextLong());
}
}
% time java -Djava.security.egd=file:/dev/urandom JRand
Ok: 8609191756834777000
java -Djava.security.egd=file:/dev/urandom JRand
0.11s user 0.03s system 115% cpu 0.117 total
% time java -Djava.security.egd=file:/dev/./urandom JRand
Ok: -3573266464480299009
java -Djava.security.egd=file:/dev/./urandom JRand
0.11s user 0.03s system 116% cpu 0.116 total
% time java -Djava.security.egd=file:/dev/urandom JRand
Ok: 6677107889555365492
java -Djava.security.egd=file:/dev/urandom JRand
0.14s user 0.02s system 9% cpu 1.661 total
% time java -Djava.security.egd=file:/dev/./urandom JRand
Ok: 5008413661952823775
java -Djava.security.egd=file:/dev/./urandom JRand
0.12s user 0.02s system 99% cpu 0.145 total