MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / GenerateRandomCharsKey

Function GenerateRandomCharsKey

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

Source from the content-addressed store, hash-verified

157}
158
159func GenerateRandomCharsKey(length int) (string, error) {
160 b := make([]byte, length)
161 maxI := big.NewInt(int64(len(keyChars)))
162
163 for i := range b {
164 n, err := crand.Int(crand.Reader, maxI)
165 if err != nil {
166 return "", err
167 }
168 b[i] = keyChars[n.Int64()]
169 }
170
171 return string(b), nil
172}
173
174func GenerateRandomKey(length int) (string, error) {
175 bytes := make([]byte, length*3/4) // 对于48位的输出,这里应该是36

Callers 2

requestOpenAI2MistralFunction · 0.92
GenerateKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected