crypto/rand
Go's cryptographically secure random source, backed by the operating system. Use it for anything an attacker must not guess: tokens, keys, secrets. math/rand is predictable and only fit for simulations and sampling.
Minimal example
b := make([]byte, 32)
rand.Read(b)
token := hex.EncodeToString(b)Learn this concept
Lesson 3.1 · Password hashing and random secretsUsed in exercises
Exercise 3.3 · POST /v1/auth/*: signup, login and refresh Exercise 3.22 · POST /v1/auth/refresh: detect token reuseRelatedRefresh token