If you want a cryptographically strong random numbers in Java, you use SecureRandom
. Unfortunately, SecureRandom
can be very slow. If it uses
I had a similar problem with calls to SecureRandom
blocking for about 25 seconds at a time on a headless Debian server. I installed the haveged
daemon to ensure /dev/random
is kept topped up, on headless servers you need something like this to generate the required entropy.
My calls to SecureRandom
now perhaps take milliseconds.