MCPcopy
hub / github.com/opencloud-eu/opencloud / generateString

Function generateString

pkg/generators/password.go:37–48  ·  view source on GitHub ↗
(chars string, length int)

Source from the content-addressed store, hash-verified

35}
36
37func generateString(chars string, length int) (string, error) {
38 ret := make([]byte, length)
39 for i := 0; i < length; i++ {
40 num, err := rand.Int(rand.Reader, big.NewInt(int64(len(chars))))
41 if err != nil {
42 return "", err
43 }
44 ret[i] = chars[num.Int64()]
45 }
46
47 return string(ret), nil
48}

Callers 2

GenerateRandomPasswordFunction · 0.85
GenerateRandomStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected