Files
backroad/api/internal/randomstring/random_string.go
Devon Steenberg 84b4b30f21 fix(rand): Use crypto/rand instead of math/rand in FIPS mode [BE-12071] (#961)
Co-authored-by: codecov-ai[bot] <156709835+codecov-ai[bot]@users.noreply.github.com>
2025-08-06 10:19:15 +12:00

15 lines
362 B
Go

package randomstring
import "github.com/portainer/portainer/pkg/librand"
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[librand.Intn(len(letterBytes))]
}
return string(b)
}