2023-04-25 18:43:01 +02:00
|
|
|
package misc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/rand"
|
|
|
|
)
|
|
|
|
|
|
|
|
func RandomString(n int) string {
|
|
|
|
var letters = []rune("abcdefghijklmnopqrstuvwxyz0123456789")
|
|
|
|
|
|
|
|
s := make([]rune, n)
|
|
|
|
for i := range s {
|
|
|
|
s[i] = letters[rand.Intn(len(letters))]
|
|
|
|
}
|
|
|
|
return string(s)
|
|
|
|
}
|
2024-05-04 17:06:01 +02:00
|
|
|
|
|
|
|
func NewLoginCookie(n int) string {
|
|
|
|
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
|
|
|
|
|
|
|
s := make([]rune, n)
|
|
|
|
for i := range s {
|
|
|
|
s[i] = letters[rand.Intn(len(letters))]
|
|
|
|
}
|
|
|
|
return string(s)
|
|
|
|
}
|