corda / net.corda.core.crypto / safeRandomBytes

# safeRandomBytes

`fun safeRandomBytes(numOfBytes: Int): ByteArray`

Generate a securely random ByteArray of requested number of bytes. Usually used for seeds, nonces and keys.

### Parameters

`numOfBytes` - how many random bytes to output.

### 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 random ByteArray.