simplify random string generation

This commit is contained in:
Loredana Crusoveanu 2020-11-20 13:48:38 +02:00
parent 43fad6ba95
commit 95fbc41ce3
1 changed files with 1 additions and 1 deletions

View File

@ -54,7 +54,7 @@ class RandomStringUnitTest {
random.nextBytes(bytes)
var randomString = (0..bytes.size - 1).map { i ->
charPool.get((bytes[i] and 0xFF.toByte() and (charPool.size-1).toByte()).toInt())
charPool[random.nextInt(charPool.size)]
}.joinToString("")
assert(randomString.matches(Regex(ALPHANUMERIC_REGEX)))