Skip to content

Seeded randomness

Random-looking numbers generated from a starting value, the seed, so the same seed always produces exactly the same sequence.

Also called seeded PRNG.

Math.random() can't be replayed. Whatever it did, it did. A seeded generator (a PRNG, or pseudo-random number generator) takes a seed and produces the same sequence every single time you give it that seed.

That replay is the feature. In Hattle, each draw got a seed made of football words and four digits, like frenzy-rocket-4821. The seed was hashed into a number, a small mulberry32-style generator turned that into a sequence, and the sequence drove the Fisher-Yates shuffle that dealt the teams. Paste the seed into the verify page and you get the identical draw. Proof instead of trust.

The flip side: never use it for anything secret. Tokens and passwords need crypto.getRandomValues(), because anyone who knows or guesses the seed can rebuild the whole sequence. Publishing the seed is great for a sweepstake. For a password, it's a disaster.

Related:Fisher-Yates shuffle.

Where I've used it: