You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/api/internal/randomstring/random_string.go

15 lines
326 B

package randomstring
import "math/rand"
const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789"
// RandomString returns a random lowercase alphanumeric string of length n
func RandomString(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
}
return string(b)
}