corda / net.corda.core.crypto / newSecureRandom


fun newSecureRandom(): SecureRandom

Get an instance of SecureRandom to avoid blocking, due to waiting for additional entropy, when possible. In this version, the NativePRNGNonBlocking is exclusively used on Linux OS to utilize dev/urandom because in high traffic /dev/random may wait for a certain amount of "noise" to be generated on the host machine before returning a result.

On Solaris, Linux, and OS X, if the entropy gathering device in is set to file:/dev/urandom or file:/dev/random, then NativePRNG is preferred to SHA1PRNG. Otherwise, SHA1PRNG is preferred.


NoSuchAlgorithmException - thrown if "NativePRNGNonBlocking" is not supported on the JVM or if no strong SecureRandom implementations are available or if Security.getProperty("securerandom.strongAlgorithms") is null or empty, which should never happen and suggests an unusual JVM or non-standard Java library.

a SecureRandom object.