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