๐ŸŽฒ Secure Random Integer Generator

Generates an unbiased, uniform random integer using the Web Crypto API and rejection sampling.

Generating...

Enter a minimum and maximum value to generate an unbiased, uniformly distributed random integer within that range, using your browser's Web Crypto API (a cryptographically secure random number generator). It avoids the "modulo bias" common with naive modulo-based random number generation by using rejection sampling.

How to use

  1. Enter a minimum and maximum value.
  2. The generated random integer is shown automatically.
  3. Click "Regenerate" to generate a new value.

FAQ

What is modulo bias?

Taking a random byte value modulo the range size introduces a slight bias toward smaller values whenever the range isn't a power of two. This tool avoids that bias entirely using a technique called rejection sampling, producing a truly uniform distribution.

How is this different from Math.random()?

Math.random() is a pseudo-random number generator with no cryptographic security guarantee. This tool uses the Web Crypto API (crypto.getRandomValues), making it better suited for use cases involving drawings/lotteries or security.

Is the generated value sent anywhere?

No. All processing happens entirely in your browser โ€” the generated value is never sent to a server.