Files
atahango/pkg/utils/token.go
Beyhan Oğur bbbf76b184 first commit
2026-04-26 21:35:24 +03:00

16 lines
346 B
Go

package utils
import (
"crypto/rand"
"encoding/hex"
)
// GenerateSecureToken returns a cryptographically random hex string (e.g. for email verification).
func GenerateSecureToken(byteLength int) (string, error) {
b := make([]byte, byteLength)
if _, err := rand.Read(b); err != nil {
return "", err
}
return hex.EncodeToString(b), nil
}