Guide

Understanding Pseudorandom and Cryptographically Secure Randomness

Updated · 2 min read

What separates an ordinary pseudorandom generator from a cryptographically secure one, why Math.random is not for passwords, and what to use instead.

On this page

Not all “random” numbers are equal. The key question is: could someone predict the next value?

Ordinary pseudorandom generators

General-purpose PRNGs such as the Mersenne Twister (used by Python’s random module) or the generator behind JavaScript’s Math.random() aim for good statistical spread and speed. They are fine for simulations, shuffling a playlist or picking a game level.

They are not built to resist an attacker. With enough observed outputs, the internal state of some of these generators can be worked out, and then future values can be predicted.

Cryptographically secure generators (CSPRNGs)

A CSPRNG is designed so that, even if an attacker sees many outputs, they cannot feasibly predict the next one or recover earlier ones. It is seeded from unpredictable system entropy and designed to stay secure over time.

NeedOrdinary PRNGCSPRNG
Games, simulationsGoodAlso fine
Reproducible results (with a seed)YesNo, by design
Passwords, tokens, keysDo not useUse this
Fair giveawaysAcceptableBetter

What to use

  • Browser JavaScript: crypto.getRandomValues(), not Math.random().
  • Python: the secrets module, not random.
  • Spreadsheets: built-in functions are fine for sampling, not for secrets.

What ToolMuti does

Every ToolMuti tool, from the random password generator to the random number generator, uses crypto.getRandomValues() and maps raw bits to your range without bias. That gives cryptographically secure pseudorandomness. This is not physical or quantum randomness; read hardware random number generators explained for that difference.

Even so, treat any website as one convenience, not as the only protection for high-value secrets. For important accounts, use a reputable password manager and long, unique passwords.

Try the tools

More guides