nextUBytes
Fills the specified unsigned byte array with random bytes and returns it.
@ExperimentalUnsignedTypes@IgnorableReturnValuefun Random.nextUBytes(array: UByteArray): UByteArray(source)
import kotlin.random.Random
import kotlin.experimental.ExperimentalUnsignedTypes
@OptIn(ExperimentalUnsignedTypes::class)
fun main() {
val bytes = UByteArray(10)
Random.nextUBytes(bytes)
println(bytes.joinToString(", ") { it.toString() })
}