MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / GenerateRandomKey

Function GenerateRandomKey

common/utils.go:174–180  ·  view source on GitHub ↗
(length int)

Source from the content-addressed store, hash-verified

172}
173
174func GenerateRandomKey(length int) (string, error) {
175 bytes := make([]byte, length*3/4) // 对于48位的输出,这里应该是36
176 if _, err := crand.Read(bytes); err != nil {
177 return "", err
178 }
179 return base64.StdEncoding.EncodeToString(bytes), nil
180}
181
182func GenerateKey() (string, error) {
183 //rand.Seed(time.Now().UnixNano())

Callers 1

GenerateAccessTokenFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected