Random Numbers: How Random Is Your Generator?

Random Numbers: How Random Is Your Generator?

“Pick a random number between 1 and 100.” The number in your head isn’t random — humans avoid 1, 100, and repeating digits. Computers have the same problem in reverse: their “random” numbers are often too predictable.

The two kinds of generators

  • Pseudo-random (PRNG): a mathematical formula that produces numbers that look random. Given the same seed, the sequence repeats exactly. Fine for games and simulations — broken for anything adversarial.
  • Cryptographically secure (CSPRNG): randomness drawn from real-world entropy (hardware noise, timing jitter), engineered so no one can predict the next number. Used for keys, passwords, and security.

The practical difference: a PRNG’s sequence can be predicted if an attacker learns its state — which is how some lottery and casino “random number” systems have been beaten. A CSPRNG resists that.

What our generator uses

The random number generator uses your browser’s CSPRNG (crypto.getRandomValues) — the same source used for encryption keys. Options cover the everyday cases:

  • Range and count: min/max, and how many numbers.
  • Uniqueness: “no repeats” for picking winners or dealing hands.
  • Decimals: from integers to six decimal places.
  • Sorting: ascending output for readable lists.

When the type of randomness matters

  • Raffles, contests, seat assignments → use a CSPRNG. Predictability here is a fairness bug.
  • Games, art, casual use → either kind is fine.
  • Anything crypto → CSPRNG only, no exceptions.

True randomness is a resource your computer mines from the physical world. The generator taps it for you — so when you need “actually random,” you get actually random.