random.go 248 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. _, err := io.ReadFull(rand.Reader, id)
  10. if err != nil {
  11. panic(err) // This shouldn't happen
  12. }
  13. return hex.EncodeToString(id)
  14. }