secureRandomBytes

fun secureRandomBytes(numOfBytes: Int): ByteArray

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

Return

a random ByteArray.

Parameters

numOfBytes

how many random bytes to output.

Throws

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.