CSPRNG Random Number & Team Shuffler
Generate cryptographically secure random numbers without modulo bias, split names into balanced teams, pick raffle winners, and roll polyhedral dice. 100% private and client-side.
Cryptographic & Statistical Suite: Generating complex passwords or multi-word passphrases using hardware entropy? Create secure credentials with our CSPRNG Password Generator. To calculate probability odds, sample sizes, and percentage margins of error, use our Master Percentage Calculator Hub.
True Randomness vs. Pseudo-Randomness: Why Math.random() Fails
Most basic web applications utilize JavaScript's built-in Math.random() method. In computer science and statistical testing, this is a flawed implementation for lotteries, team shuffling, or scientific sampling:
Math.random(): Pseudo-Random Number Generator (PRNG) relying on deterministic algorithms (like xorshift128+). An observer who tracks past outputs can reconstruct the internal state and predict future outputs.Web Crypto API (CSPRNG): Cryptographically Secure Pseudo-Random Number Generator sampling physical hardware entropy (CPU clock jitter, thermal noise, interrupt timings) to ensure absolute unpredictability.
Urban Mixo strictly utilizes window.crypto.getRandomValues() combined with rejection sampling, guaranteeing that every integer in your range possesses an identical, mathematically uniform probability of selection.
RNG Architecture Comparison: LCG vs. Mersenne Twister vs. CSPRNG
Understanding random number generators requires distinguishing between statistical algorithms and cryptographic primitives:
| RNG Architecture | Algorithm Basis | Cryptographically Secure | Vulnerability & Primary Application |
|---|---|---|---|
| Linear Congruential (LCG) | $X_{n+1} = (aX_n + c) \bmod m$ | No (Insecure) | Exhibits lattice structures in multi-dimensional space; legacy C/C++ rand(). |
| Mersenne Twister (MT19937) | Linear recurrence on Mersenne prime $2^{19937}-1$ | No (Insecure) | State can be completely reconstructed after observing 624 outputs; standard in Python/Ruby. |
| Web Crypto CSPRNG | OS-level hardware entropy + ChaCha20 / AES-CTR | Yes (Gold Standard) | Computationally infeasible to reverse or predict; banking, tokenization, and fair draws. |
Understanding and Eliminating Modulo Bias
A naive method for generating an integer between $0$ and $N-1$ is to take a 32-bit random integer and compute randomInt % N. When $2^{32}$ (4,294,967,296) is not evenly divisible by $N$, smaller numbers are slightly more likely to be chosen than larger ones (modulo bias). Our engine applies rejection sampling:
Range Limit = Floor(2^32 ÷ Range) × RangeAny 32-bit integer generated above this limit is discarded and regenerated, ensuring 100% uniform mathematical distribution across the entire range without bias.
The Fisher-Yates (Knuth) Shuffle Algorithm
When shuffling teams or randomized lists, simple sorting hacks (like arr.sort(() => Math.random() - 0.5)) produce mathematically biased permutations. Urban Mixo implements the gold-standard Fisher-Yates (Knuth) shuffle:
- The algorithm traverses the array from the final element down to the first ($O(n)$ linear time complexity).
- At each position $i$, it chooses an unbiased cryptographic random index $j$ such that $0 \le j \le i$, and swaps elements $A[i]$ and $A[j]$.
- This ensures that all $n!$ (n factorial) possible team configurations have an equal probability of occurrence.
To inspect and compare randomized list permutations or diff file changes, compare texts with our Text Diff Checker & Code Comparison Suite.