Random Number Generator
Generate cryptographically-random integers in a range.
Overview
The Random Number Generator produces cryptographically-secure random integers in a chosen range. Whether you need a single PIN, a list of unique lottery picks or a stream of dice rolls, the generator returns values uniformly distributed across the inclusive [min, max] interval.
It is built for raffle organisers, contest moderators, security engineers seeding tokens and developers populating test fixtures. Unlike Math.random()-style generators, the output here is suitable for security-sensitive contexts because it draws from the OS cryptographic RNG.
How it works
The generator pulls random bytes from a CSPRNG (cryptographically secure pseudo-random number generator), interprets them as an unsigned integer and uses rejection sampling to map them uniformly into the requested range. Rejection sampling avoids the small bias you get from modulo reduction when the range isn't a power of two.
For "unique" mode the generator picks without replacement: it draws until enough distinct values fit the count or, for moderate counts, shuffles the full candidate list via a Fisher-Yates style algorithm. The result is mathematically guaranteed to be a uniform sample.
Examples
range 1..10, one number → e.g. 7
range 1..49, six unique numbers → e.g. 4, 11, 23, 27, 35, 42
range 0..255, 100 numbers → uniform sample of byte values
range 1..6, ten dice rolls → e.g. 3, 5, 1, 6, 2, 4, 4, 6, 3, 2
FAQ
Is it cryptographically secure?
Yes — the seed comes from the OS CSPRNG, so output is suitable for tokens, nonces and other security uses.
Why is rejection sampling needed?
Plain modulo of a random byte introduces slight bias unless the range divides evenly into 256. Rejection sampling discards out-of-range draws and retries.
Can I seed it for reproducibility?
This tool is unseeded — useful for unbiased draws but not for reproducible tests. Use a seeded PRNG when reproducibility matters.
What about decimal numbers?
The generator returns integers. For floats, divide an integer draw by the maximum to get values in [0, 1).
How fair are unique draws?
A Fisher-Yates shuffle gives a perfectly uniform permutation, so every combination of the requested size is equally likely.