nextString

fun Random.nextString(length: Int, alphabet: String): String

Returns a random string of exactly length characters drawn from alphabet.

Each character is chosen independently and uniformly at random from the positions of alphabet. A length of zero yields the empty string.

Parameters

length

the number of characters to generate, must be non-negative.

alphabet

the characters to choose from.

Throws

if length is negative or alphabet is empty.