gokins/core/vars.go
2020-09-30 20:26:50 +08:00

24 lines
438 B
Go

package core
import (
"math/rand"
"time"
)
var (
JwtKey = ""
JwtCookiePath = "/"
)
// RandomString 随机生成字符串
func RandomString(l int) string {
str := "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
bts := []byte(str)
var result []byte
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < l; i++ {
result = append(result, bts[r.Intn(len(bts))])
}
return string(result)
}