1 Star 0 Fork 0

han / keyauth-g7

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
token.go 569 Bytes
一键复制 编辑 原始数据 按行查看 历史
han 提交于 2023-07-23 23:49 . 11
package utils
import (
"math/rand"
"strings"
"time"
)
// MakeBearer https://tools.ietf.org/html/rfc6750#section-2.1
// b64token = 1*( ALPHA / DIGIT /"-" / "." / "_" / "~" / "+" / "/" ) *"="
func MakeBearer(lenth int) string {
charlist := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
t := make([]string, lenth)
rand.Seed(time.Now().UnixNano() + int64(lenth) + rand.Int63n(10000))
for i := 0; i < lenth; i++ {
rn := rand.Intn(len(charlist))
w := charlist[rn : rn+1]
t = append(t, w)
}
token := strings.Join(t, "")
return token
}
Go
1
https://gitee.com/hanshengjian/keyauth-g7.git
git@gitee.com:hanshengjian/keyauth-g7.git
hanshengjian
keyauth-g7
keyauth-g7
23cb155209a5

搜索帮助

53164aa7 5694891 3bd8fe86 5694891