random.go 249 B

12345678910111213141516
  1. package utils
  2. import (
  3. "crypto/rand"
  4. "encoding/hex"
  5. "io"
  6. )
  7. func RandomString() string {
  8. id := make([]byte, 32)
  9. if _, err := io.ReadFull(rand.Reader, id); err != nil {
  10. panic(err) // This shouldn't happen
  11. }
  12. return hex.EncodeToString(id)
  13. }