package webhook

import (
	"crypto/rand"
	"crypto/sha256"
	"encoding/hex"
)

// genToken generates a 64-character hex token using crypto/rand.
func genToken() string {
	b := make([]byte, 32)
	if _, err := rand.Read(b); err != nil {
		panic("crypto/rand failed: " + err.Error())
	}
	return hex.EncodeToString(b)
}

// hashToken returns the SHA-256 hex digest of a token, suitable for storage.
func hashToken(token string) string {
	h := sha256.Sum256([]byte(token))
	return hex.EncodeToString(h[:])
}
