Created
May 17, 2019 09:59
-
-
Save twiceyuan/b80822f3505109352b1355b8add578a3 to your computer and use it in GitHub Desktop.
[nonce generator] 随机字符串生成器 #Kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun generateNonce(size: Int): String { | |
val nonceScope = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
val scopeSize = nonceScope.length | |
val nonceItem: (Int) -> Char = { nonceScope[(scopeSize * Math.random()).toInt()] } | |
return Array(size, nonceItem).joinToString("") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment