mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-06-21 17:12:47 +02:00
21 lines
327 B
Go
21 lines
327 B
Go
package api
|
|
|
|
import (
|
|
"crypto/rand"
|
|
)
|
|
|
|
const randRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
|
const lenRandRunes = len(randRunes)
|
|
|
|
func RandString(length int) string {
|
|
b := make([]byte, length)
|
|
|
|
rand.Read(b)
|
|
|
|
for i := range b {
|
|
b[i] = randRunes[int(b[i])%lenRandRunes]
|
|
}
|
|
|
|
return string(b)
|
|
}
|