gokins/core/vars.go

24 lines
438 B
Go
Raw Normal View History

2020-07-10 11:58:41 +08:00
package core
2020-09-30 20:26:50 +08:00
import (
"math/rand"
"time"
)
2020-07-10 11:58:41 +08:00
var (
JwtKey = ""
JwtCookiePath = "/"
)
2020-09-30 20:26:50 +08:00
// 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)
}