The function as written is modulo biased where the first 8 characters in the list of validChars have a higher probability of being in the random string than the latter ones.
Proposed change:
func MakeRandomString(n int) string {
const validChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
result := make([]byte, n)
for x = 0; x < n; x++ {
result = validChars[rand.Intn(len(validChars))]
}
return string(result)
}
https://github.com/gravitl/netmaker/blob/1b62af180a7b489b37672a99efbf8a56d4a9c808/netclient/ncutils/netclientutils.go#L44
The function as written is modulo biased where the first 8 characters in the list of validChars have a higher probability of being in the random string than the latter ones.
Proposed change: