mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-04 22:23:02 +00:00
27 lines
420 B
Go
27 lines
420 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)
|
|
}
|
|
|
|
func NewCSRFToken() string {
|
|
return NewRandId(24)
|
|
}
|