package util import ( "crypto/rand" "encoding/hex" "log" ) // GenerateRandomString generates a random hex string from a random array of "n" bytes func GenerateRandomString(n int) string { b := make([]byte, n) _, err := rand.Read(b) if err != nil { log.Fatal(err) } return hex.EncodeToString(b) }