Complete RNG Reference

Random Number Generator Guide: Fair Numbers, Crypto Option

From dice rolls to cryptography -- everything you need to know about random number generation, pseudo-random vs true random, crypto-secure APIs, and real-world applications.

Crypto-Secure 100% Private Spin Wheel
By Karan Kumar Updated August 17, 2026 14 min read
Quick Summary

01What Is a Random Number Generator

A brief history of randomness and the tool that powers everything from lotteries to encryption.

A random number generator (RNG) is a computational algorithm, hardware device, or software tool that produces a sequence of numbers lacking any predictable pattern. The concept dates back thousands of years -- ancient civilizations used dice, bones, and lots to introduce randomness into decisions.

In the modern era, random number generators power everything from lottery draws and video game loot drops to cryptography and scientific simulations. Without reliable randomness, online security would collapse, statistical research would be biased, and games of chance would be rigged.

Ancient Origins

Dice made from animal bones date back to 3000 BC. The Chinese used sticks for divination during the Shang Dynasty. Romans tossed metal discs (tesserae) in games of chance.

The Computer Era

John von Neumann proposed the middle-square method in 1946 -- the first algorithm for generating pseudo-random numbers on a computer. Modern algorithms like Mersenne Twister are far more sophisticated.

Online RNG Tools

Browser-based RNG tools use JavaScript's Math.random() or the Web Crypto API to generate numbers instantly. They eliminate the need for hardware devices while maintaining statistical quality.

Why It Matters Today

Every secure connection you make online relies on cryptographic randomness. Passwords, encryption keys, session tokens, and two-factor authentication codes all depend on unpredictable random numbers.

02Why Randomness Matters

From fair decisions to unbreakable encryption, randomness is the invisible force behind trust and security.

Randomness is not just about picking a lucky number. It is a fundamental requirement for fairness, security, and scientific validity. Without true randomness, outcomes can be predicted, manipulated, or biased.

Fairness

Raffles, giveaways, and classroom activities need unpredictable results so every participant has an equal chance. A predictable RNG undermines the entire purpose of a random draw.

Security

Encryption keys, passwords, and session tokens must be unpredictable. If an attacker can guess or compute your random values, they can decrypt your data or impersonate you.

Science

Monte Carlo simulations, randomized controlled trials, and statistical sampling all depend on random assignment to eliminate bias and produce valid results.

Gaming

Video game mechanics like critical hits, loot drops, and procedural generation rely on RNG to create varied, unpredictable gameplay experiences.

Key Insight

The quality of your randomness directly determines the integrity of your outcome. A biased RNG in a lottery can lead to legal disputes. A weak RNG in cryptography can lead to data breaches.

03True Random vs Pseudo-Random

Understanding the critical difference between hardware-based and algorithm-based randomness.

Not all random numbers are created equal. The distinction between True Random Number Generators (TRNG) and Pseudo-Random Number Generators (PRNG) determines which applications they are suitable for.

FeatureTrue RNG (TRNG)Pseudo-RNG (PRNG)
SourcePhysical phenomena (atmospheric noise, radioactive decay, thermal noise)Mathematical algorithms seeded with an initial value
PredictabilityUnpredictable -- no pattern existsPredictable if the seed is known
SpeedSlower -- limited by physical measurementVery fast -- billions of numbers per second
ReproducibilityCannot be reproducedSame seed produces same sequence
Best ForCryptography, high-security applicationsGames, simulations, general-purpose use

PRNG algorithms include Linear Congruential Generator (LCG), Xorshift, and Mersenne Twister. Each uses a different mathematical formula to produce sequences that pass statistical randomness tests.

TRNG sources include atmospheric noise (used by Random.org), keystroke timing, mouse movements, and hardware random number generators (HRNG) built into modern CPUs.

04Cryptographic Randomness (CSPRNG)

Why Math.random() is not enough for security and how the Web Crypto API solves the problem.

A Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) is a PRNG that satisfies additional requirements making it suitable for cryptographic use. Even if an attacker knows some output values, they cannot predict future or past values.

In web browsers, the Web Crypto API provides crypto.getRandomValues(), which generates cryptographically secure random numbers. This is the gold standard for any security-sensitive application in the browser.

MethodSecurity LevelUse Case
Math.random()Low -- predictable with enough outputGames, animations, non-sensitive randomization
crypto.getRandomValues()High -- cryptographically securePasswords, tokens, encryption keys, 2FA codes
Hardware RNG (HRNG)Highest -- physical entropy sourceServer-side key generation, high-security systems
Security Warning

Never use Math.random() for generating passwords, API keys, or encryption secrets. Studies have shown that Math.random() outputs can be predicted after observing as few as 10 consecutive values.

05How Computers Generate Random Numbers

Seeds, algorithms, and the mathematics behind pseudo-random sequences.

Computers are deterministic machines -- they cannot produce truly random numbers on their own. Instead, they use algorithms that take an initial value (called a seed) and apply mathematical transformations to produce a sequence of numbers that appear random.

01

The Seed

Every PRNG starts with a seed value. If you use the same seed twice, you get the same sequence. This is useful for reproducing experiments but dangerous for security. Common seed sources include the current time, system entropy pools, or user input.

02

The Algorithm

Popular algorithms include Linear Congruential Generator (simple but weak), Xorshift (fast and good statistical quality), and Mersenne Twister (excellent distribution, used by most programming languages by default).

03

The Output

The algorithm produces a sequence of numbers. For LCG, each number is computed as: next = (a * current + c) mod m. The constants a, c, and m are carefully chosen to maximize the period (how long before the sequence repeats).

04

The Period

Every PRNG eventually repeats. Mersenne Twister has a period of 2^19937-1 -- a number so large it will never repeat in practice. Poorly designed generators may repeat after just a few million values.

06AFFLIGO RNG Tool Features

Unique mode, decimals, a crypto toggle, spin animation, and sort/format controls — what each does below.

AFFLIGO's Random Number Generator combines ease of use with advanced features that power users need. Every feature is designed with privacy and flexibility in mind.

Unique & Duplicate Modes

Toggle between allowing repeated numbers or ensuring every generated number is unique. Essential for raffles where you cannot pick the same winner twice.

Decimal Support

Generate numbers with up to 5 decimal places for scientific calculations, statistical sampling, and precise measurements beyond simple integers.

Crypto-Secure Toggle

Switch from standard Math.random() to the Web Crypto API for cryptographically secure generation when security matters.

Spin Wheel Animation

An engaging slot-machine-style animation for single-number picks. Perfect for raffles, classroom draws, and game nights.

Sort & Format Controls

Sort results ascending, descending, or leave in generation order. Format output as comma-separated values or one number per line.

Works Offline

Loads once, then generates without a connection — usable on stage or in classrooms with spotty wifi.

07Step-by-Step Guide

Set the range, pick the toggles, hit Generate, copy the result — the four stages below.

01

Set the Range

Enter a minimum value and maximum value to define the boundaries. For example, min=1 and max=100 generates numbers between 1 and 100 inclusive.

Random number generator min max and count inputs highlighted
02

Choose Options

  • Unique-only: No duplicates -- each number appears at most once
  • Decimal: Toggle on for fractional numbers with configurable precision
  • Crypto-secure: Enable for security-sensitive generation via Web Crypto API
Unique decimal and crypto toggle options highlighted in random number generator
03

Generate Numbers

Click Generate to produce your random numbers. Use the sort controls (None / Ascending / Descending) and format controls (Comma / New Line) to arrange the output.

Random number chips generated with Generate button highlighted
04

Copy or Spin

Click Copy All to save results to your clipboard. For a single number with a visual reveal, use the Spin Wheel for an animated slot-machine effect.

Copy All button sort controls and format controls highlighted in random number generator

08Random Number Distributions

Understanding uniform, normal, and other distributions -- and when to use each.

A probability distribution describes how random values are spread across a range. The distribution you choose determines which values are more likely to appear.

DistributionShapeCommon Use
UniformEvery value equally likelyRaffles, lotteries, general-purpose RNG
Normal (Gaussian)Bell curve -- most values cluster around the meanHeight, weight, test scores, natural phenomena
ExponentialMost values small, fewer large valuesWaiting times, failure rates, queue lengths
BernoulliOnly two outcomes (0 or 1)Coin flips, binary decisions, success/failure
PoissonCount of events in a time periodArrivals per hour, defects per batch, calls per minute

AFFLIGO's random number generator produces a uniform distribution by default -- every number in the range has an equal probability of being selected. This is the standard expectation for raffles, games, and general-purpose use.

09Unique vs Duplicate Mode

When to allow repeats and when every number must be one-of-a-kind.

Duplicate mode (default) allows the same number to appear multiple times. This is correct for rolling dice, spinning a wheel, or simulating independent events where the same outcome can occur twice.

Unique mode ensures no number appears more than once. This is essential for assigning numbers to participants, picking multiple winners, or any scenario where repetition would cause problems.

ScenarioModeWhy
Raffle with 1 winnerEitherOnly one number picked -- duplicates are irrelevant
Raffle with 3 winnersUniqueCannot pick the same winner twice
Rolling a dice 10 timesDuplicateDice can land on the same face repeatedly
Assigning seat numbersUniqueEach person gets one unique seat
Simulating coin flipsDuplicateHeads or tails can occur any number of times
Picking lottery numbersUniqueEach number on a ticket is unique
Pro Tip

When using unique mode, the maximum quantity you can generate is limited by the range size. You cannot generate 100 unique numbers from a range of 1-50.

10Decimal Numbers vs Integers

Choosing between whole numbers and fractional precision for your use case.

Integers are whole numbers without fractional parts. They are the standard for raffles, lottery draws, seat assignments, and any scenario where only whole values make sense.

Decimal numbers include fractional parts and are essential for scientific calculations, statistical sampling, and any application requiring precision beyond whole values.

TypeExampleBest For
Integer42Raffles, lottery, seat numbers, dice rolls, counting
1 Decimal42.3Temperature readings, basic measurements
2 Decimals42.37Currency, weight, distance measurements
3 Decimals42.371Scientific experiments, precision engineering
5 Decimals42.37129Statistical sampling, Monte Carlo simulations

11The Spin Wheel -- Visual Randomness

How the animated slot-machine reveal works and when to use it.

The Spin Wheel is a visual animation that cycles through random numbers before landing on a final result. It provides an engaging, game-like experience that adds excitement to single-number generation.

Unlike the standard Generate button which instantly shows results, the spin wheel creates suspense and anticipation. This makes it ideal for live events, classroom activities, and any scenario where the reveal moment matters as much as the result.

Best For

Raffles, classroom draws, game nights, live events, and any single-pick scenario where you want a dramatic reveal.

How It Works

The animation rapidly cycles through numbers in your specified range, gradually slowing down before landing on the final random result. The entire process takes about 1.5 seconds.

Spin Again

After the result is revealed, you can immediately spin again without re-entering your range settings. This is useful for picking multiple winners in sequence.

12Use Cases: Raffles & Giveaways

How to run a fair, transparent random draw for any event.

Raffles and giveaways are the most common use case for online random number generators. The key requirement is fairness -- every participant must have an equal probability of being selected.

01

Assign Numbers to Participants

Give each participant a unique number. If you have 50 people, assign numbers 1-50. Keep a list mapping numbers to names for verification.

02

Set the Range

Set min=1 and max=50 (or however many participants you have). This ensures every person is equally likely to be picked.

03

Enable Unique Mode

If picking multiple winners, enable unique mode to prevent the same person from being drawn twice. For a single winner, either mode works.

04

Generate & Announce

Click Generate (or use the Spin Wheel for a live event). Announce the winning number and match it to your participant list.

13Use Cases: Lottery & Gaming

How randomness powers games of chance and video game mechanics.

The lottery industry generates over $300 billion in annual revenue worldwide, and every draw depends on secure random number generation. Similarly, the video game industry uses RNG to create dynamic, unpredictable experiences.

Lottery Draws

Official lotteries use hardware random number generators (HRNG) or certified software CSPRNGs. Some use atmospheric noise, others use thermal noise from semiconductors.

Video Game Loot

Games like Fortnite, Diablo, and Genshin Impact use weighted RNG for loot drops. Rare items have lower probability, creating excitement and rarity value.

Critical Hits

RPGs and strategy games use RNG for critical hit chances, dodge probabilities, and random event triggers. A 25% crit chance means roughly 1 in 4 attacks will crit.

Procedural Generation

Games like Minecraft and No Man's Sky use RNG to generate entire worlds, ensuring each playthrough is unique.

14Use Cases: Security & Passwords

Why cryptographic randomness is non-negotiable for security applications.

Every secure digital system depends on random numbers. Encryption keys, passwords, session tokens, two-factor authentication codes, and nonce values all require cryptographically secure randomness.

The Web Crypto API's crypto.getRandomValues() is the standard for generating secure random values in web browsers. AFFLIGO's crypto-secure toggle activates this API for any generation.

Never Do This

Do not use date/time, sequential numbers, or user-chosen values as passwords or encryption keys. These are predictable. Always use a CSPRNG to generate security-sensitive random values.

For password generation, combine random characters from multiple character sets (uppercase, lowercase, numbers, symbols). A 16-character password generated by a CSPRNG has more entropy than a 30-character user-chosen passphrase.

15Use Cases: Science & Statistics

Monte Carlo simulations, sampling, and the role of randomness in research.

Randomness is the foundation of modern statistics and scientific research. Random sampling eliminates selection bias. Random assignment ensures experimental groups are comparable. Monte Carlo simulations use random sampling to solve complex mathematical problems.

Monte Carlo Methods

Named after the casino in Monaco, these methods use repeated random sampling to approximate complex calculations. Used in physics, finance, and machine learning.

A/B Testing

Randomly assign users to control and variant groups to measure the true impact of changes. Without random assignment, results are confounded by user differences.

Bootstrap Resampling

Generate confidence intervals by repeatedly sampling with replacement from your data. Requires high-quality random numbers to produce valid statistical estimates.

Permutation Tests

Test hypotheses by randomly permuting group labels. This non-parametric approach makes no assumptions about data distribution.

16Common Mistakes & Misconceptions

The gambler's fallacy, streaks, and why "random" does not mean "equal."

01

The Gambler's Fallacy

If a coin lands heads 5 times in a row, the next flip is still 50/50. Past random events do not influence future ones. Each flip is independent. The universe does not "owe" you tails.

02

"Random" Does Not Mean "Equal"

If you flip a coin 10 times, getting 7 heads and 3 tails is perfectly normal. True randomness produces clusters and streaks. Forced equality (exactly 5 heads, 5 tails) is actually less random.

03

Hot Hand Fallacy

Basketball players who make several shots in a row are not "hot" -- they are just on a streak. Research shows shooting percentages remain constant regardless of recent makes or misses.

04

Small Sample Bias

Humans are terrible at recognizing randomness in small samples. We see patterns where none exist. A truly random sequence of 10 coin flips might be HHTHHHTHTH -- and that is perfectly normal.

17Online vs Offline Generators

Privacy, convenience, and why browser-side generation is the safest choice.

Online generators like AFFLIGO run entirely in your browser. The JavaScript code executes locally, and no data is ever sent to a server. This makes them inherently private and safe for sensitive applications.

Offline generators include desktop applications, command-line tools, and hardware random number generators. These are useful when you need integration with local systems or maximum control over entropy sources.

Generator typeProsCons
Browser-side (AFFLIGO)No downloads, instant access, 100% private, works on any deviceLimited by JavaScript performance
Desktop AppOffline access, system integrationRequires installation, potential malware risk
Hardware RNGTrue randomness from physical phenomenaExpensive, requires special hardware
Command-LineScriptable, fast, integrates with pipelinesRequires technical knowledge

18Best Practices

Choosing the right mode, range, and settings for your specific use case.

01

Match Mode to Scenario

Use unique mode for raffles, seat assignments, and any scenario where repeats cause problems. Use duplicate mode for dice rolls, coin flips, and independent events.

02

Enable Crypto When Needed

For passwords, tokens, and security-sensitive generation, always enable the crypto-secure toggle. For games, raffles, and general use, standard generation is sufficient.

03

Verify Your Range

Double-check your min and max values before generating. An off-by-one error can include or exclude the wrong boundary number.

04

Document for Transparency

For public raffles or giveaways, screenshot the generation settings and results. This provides proof of fairness and builds trust with participants.

19Frequently Asked Questions

Answers to the most common questions about random number generation.

A random number generator (RNG) is a tool, computational algorithm, or physical device designed to generate a sequence of numbers or symbols that lack any predictable pattern.
It uses mathematical algorithms to produce sequences of numbers that appear random but are actually determined by a starting value called a seed.
It depends on the use case. True RNGs use physical phenomena (like atmospheric noise) and are better for high-security applications like cryptography, while pseudo-RNGs are faster and perfectly fine for games, giveaways, and statistics.
Yes, our tool allows you to specify a quantity and check the unique-only option to ensure no duplicate numbers are drawn from your chosen range.
Simply assign a number to each participant (e.g., 1 to 100), set your min to 1 and max to 100, and generate a number to pick the winner.
Yes, our RNG generator uses cryptographic-grade randomness (crypto.getRandomValues with rejection sampling against modulo bias), giving every number in the range an equal mathematical probability of being selected.
Yes, you can toggle decimal mode to generate numbers with precision up to 5 decimal places, rather than just random integer generation.
Set any min and max your draw needs, including negatives and decimals up to 5 places. The one hard rule is uniques mode: the count cannot exceed the range size, so 10 uniques from 1-5 is refused outright.
Math.random uses a pseudo-random algorithm that is predictable if the seed is known. crypto.getRandomValues uses the Web Crypto API to produce cryptographically secure random numbers suitable for security-sensitive applications.
Modulo bias occurs when mapping a random number to a range using the modulo operator. If the range of the RNG is not evenly divisible by your desired range, some numbers appear more frequently than others. Proper RNG implementations account for this to ensure uniform distribution.
The spin wheel is a visual animation that cycles through numbers before landing on a final random result. It provides an engaging, game-like experience for single-number generation, ideal for raffles and classroom activities.
Yes, enable the crypto-secure toggle which uses the Web Crypto API (crypto.getRandomValues). It suits casual tokens and giveaway draws. For production encryption keys, use a dedicated security library or hardware RNG.
You can generate up to 1,000 random numbers in a single batch. Results can be sorted ascending, descending, or left in generation order, and formatted as comma-separated or one per line.
Yes, all number generation happens entirely in your browser using JavaScript. No data is ever sent to any server, making it completely private and secure.
A uniform distribution means every number in the range has an equal probability of being selected. This is the standard expectation for most random number generation use cases like raffles, games, and sampling.

Generate Random Numbers Now

Fast, free, no sign-up. Works offline after the first load.

Open Random Number Generator

Key Takeaways

Hands-On Tested

I generated 100 numbers in range 1-100 with the crypto toggle on: the distribution looked even with no obvious clustering, uniques mode correctly refused an impossible request (10 uniques from 1-5), and the 1.5s animation ran the same duration on repeat runs.

Sources: MDN crypto.getRandomValues docs, NIST SP 800-90A randomness recommendations.

Karan Kumar, Founder of AFFLIGO

Karan Kumar

Founder & Web Developer at AFFLIGO

Karan built AFFLIGO's Random Number Generator with crypto-secure Web Crypto mode, uniques/decimals controls, sort-format options and a spin wheel — all client-side. He tests every release on distribution fairness and impossible-request guards before publishing.

Last reviewed: October 2, 2026