internal/random/random.go
Ref: Size: 653 B History
// Package random provides small cryptographically-random helpers shared across
// the control plane, CLIs, and the integration harness — a leaf package so a
// CLI or test binary can reuse them without importing heavier deps (e.g. the
// sqlite-backed store).
package random
import (
"crypto/rand"
"encoding/hex"
)
// Hex returns n cryptographically-random bytes encoded as hex (2n chars).
// crypto/rand.Read is documented never to fail (Go 1.24+), so its error is
// intentionally ignored.
func Hex(n int) string {
b := make([]byte, n)
rand.Read(b) //nolint:errcheck // crypto/rand.Read never returns an error
return hex.EncodeToString(b)
}