random

open fun random(upper: Int): Int

Returns a random int between 0 (inclusive) and upper (exclusive).

It draws from a shared java.util.Random, which is not cryptographically secure: do not use it for tokens, IDs, salts or anything else an attacker must not guess. Use randomId() or newByteArraySalt(), which draw from java.security.SecureRandom, instead.

Return

the random value

Parameters

upper

the exclusive upper bound, which must be positive


open fun random(upper: Long): Long

Returns a random long between 0 (inclusive) and upper (exclusive).

It draws from a shared java.util.Random, which is not cryptographically secure: do not use it for tokens, IDs, salts or anything else an attacker must not guess. Use randomId() or newByteArraySalt(), which draw from java.security.SecureRandom, instead.

Return

the random value

Parameters

upper

the exclusive upper bound, which must be positive