mirror of
https://git.freesoftwareextremist.com/bloat
synced 2024-11-14 02:04:11 +00:00
22 lines
366 B
Go
22 lines
366 B
Go
package util
|
|
|
|
import (
|
|
"math/rand"
|
|
)
|
|
|
|
var (
|
|
runes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
|
|
runes_length = len(runes)
|
|
)
|
|
|
|
func NewRandId(n int) string {
|
|
data := make([]rune, n)
|
|
for i := range data {
|
|
data[i] = runes[rand.Intn(runes_length)]
|
|
}
|
|
return string(data)
|
|
}
|
|
|
|
func NewSessionId() string {
|
|
return NewRandId(24)
|
|
}
|