You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

13 lines
325 B

package net.aiterp.git.ykonsole2.domain.models
import java.security.SecureRandom
private val rand by lazy { SecureRandom() }
const val ID_LENGTH = 10
fun randomId(): String = buildString {
while (length < ID_LENGTH) {
append(rand.nextInt().toUInt().toString(16).padStart(8, '0'))
}
}.substring(0 until ID_LENGTH)