1 Star 0 Fork 0

zhen / go_demo_keyauth

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
token.go 569 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhen 提交于 2023-04-25 16:50 . 权限认证
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
}
1
https://gitee.com/easy_code/go_demo_keyauth.git
git@gitee.com:easy_code/go_demo_keyauth.git
easy_code
go_demo_keyauth
go_demo_keyauth
33290b63155e

搜索帮助