yt-gen-app/lib/templ/random-hex.go

15 lines
230 B
Go

package templ
import (
"crypto/rand"
"encoding/hex"
)
func RandomHex(n int) (string, error) {
bytes := make([]byte, n)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}