Weak Random (ARCH8115)
Key kotlin.security.weak-random · Severity warning · Category security · CWE CWE-338
Flags java.util.Random, kotlin.random.Random or Math.random used for tokens, keys, nonces or passwords.
Incorrect
Section titled “Incorrect”val token = Random.nextInt().toString(16)Correct
Section titled “Correct”val token = ByteArray(32).also { SecureRandom().nextBytes(it) }.toHex()Use SecureRandom for anything security-sensitive.