newSecureRandom - corda

corda / net.corda.core.crypto / newSecureRandom

# 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 java.security is set to file:/dev/urandom or file:/dev/random, then NativePRNG is preferred to SHA1PRNG. Otherwise, SHA1PRNG is preferred.

### Exceptions

`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.

Return
a SecureRandom object.