/dev/urandom
is non-blocking by design:
When read, the /dev/random
device will only return random bytes
within the estimated number of bits of noise in the entropy pool.
/dev/random
should be suitable for uses that need very high quality
randomness such as one-time pad or key generation. When the entropy
pool is empty, reads from /dev/random
will block until additional
environmental noise is gathered.
A read from the /dev/urandom
device will not block waiting for more
entropy. As a result, if there is not sufficient entropy in the
entropy pool, the returned values are theoretically vulnerable to a
cryptographic attack on the algorithms used by the driver.
If you replace it with /dev/random
, your program should produce a different result.