37 Star 403 Fork 75

GVPrancher/rancher

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
token.go 436 Bytes
Copy Edit Raw Blame History
package randomtoken
import (
"crypto/rand"
"math/big"
)
const (
characters = "bcdfghjklmnpqrstvwxz2456789"
tokenLength = 54
)
var charsLength = big.NewInt(int64(len(characters)))
func Generate() (string, error) {
token := make([]byte, tokenLength)
for i := range token {
r, err := rand.Int(rand.Reader, charsLength)
if err != nil {
return "", err
}
token[i] = characters[r.Int64()]
}
return string(token), nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.13

Search