mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Random strings for cookie values (#1122)
This commit is contained in:
17
pkg/utils/strings.go
Normal file
17
pkg/utils/strings.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
var characters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
|
||||
|
||||
func RandomSequence(n int) string {
|
||||
b := make([]rune, n)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
for i := range b {
|
||||
b[i] = characters[rand.Intn(len(characters))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
Reference in New Issue
Block a user