mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2025-05-01 09:34:21 +00:00
Initial commit
This commit is contained in:
commit
5e4da01c3a
43 changed files with 3429 additions and 0 deletions
22
util/rand.go
Normal file
22
util/rand.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue