Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk6 min

Random Number Generator (RNG): Types, Uses, Security, and Fair Number Generation

A practical guide to random number generators: understand PRNGs, CSPRNGs and TRNGs, choose the right source, generate unbiased ranges, and avoid common security and fairness mistakes.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A random number generator (RNG) produces numbers or bits according to a chosen distribution. Use an ordinary pseudorandom generator (PRNG) for fast, repeatable simulations and games; use a cryptographically secure PRNG (CSPRNG) for passwords, tokens, keys, and other secrets; choose a true or hardware RNG (TRNG/HRNG), or a signed external service, when physical provenance or independently verifiable public results are required.

What “random” means

Randomness is not one binary property. Depending on the task, you may need:

As an Amazon Associate I earn from qualifying purchases.

  • Unpredictability: an observer cannot forecast the next value.
  • Uniformity: outcomes occur with the intended probabilities.
  • Independence: previous outputs do not provide useful information about later ones.
  • Reproducibility: the same seed recreates a sequence for tests or simulations.
  • Auditability: others can verify how a result was produced.
  • Physical nondeterminism: values originate from a physical process rather than only an algorithm.

A sequence can be statistically convincing yet predictable, so passing randomness tests does not by itself make a generator secure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PRNG, CSPRNG, and TRNG compared

Type How it works Strengths Limitations Good uses
PRNG A deterministic algorithm expands a seed into a sequence. Very fast, inexpensive, reproducible. Anyone who obtains the seed or state may reproduce outputs; ordinary PRNGs are not for secrets. Simulations, procedural content, randomized tests, many non-adversarial games.
CSPRNG A PRNG designed to resist prediction and state-recovery attacks when correctly seeded and implemented. Suitable for security-sensitive values; usually local and low-latency. Still depends on seed entropy, state protection, correct API use, and implementation quality. Passwords, reset links, session IDs, API keys, nonces, salts, keys and one-time codes.
TRNG/HRNG Samples a physical phenomenon such as electronic or atmospheric noise. Physical source; useful where independent provenance is required. May be slower, remote, costly, biased, unavailable, or difficult to audit; physical origin alone does not prove security or fairness. Public drawings, specialized hardware, compliance or audit requirements.

NIST’s SP 800-90 framework separates entropy sources, deterministic mechanisms and constructions that combine them. SP 800-90A Rev. 1 specifies hash-, HMAC- and block-cipher-based deterministic mechanisms: NIST SP 800-90A Rev. 1. NIST’s publication list identifies SP 800-90C as final on September 25, 2025, while SP 800-90A Rev. 2 was listed as a pre-draft call for comments dated September 4, 2025: current NIST publication status. A NIST recommendation, a FIPS-validated module, a vendor marketing claim and a statistical test are different things.

#1 Best Overall
quEmpire Gaming Random Number Generator Dice 1-10,000,000
  • Roll A Random Number 1 to 10,000,000!
  • 7 Dice Set
  • Great for Random Numbers & Loot in RPGs
  • The Dungeon Master's Friend

Entropy and how computer randomness works

In this context, entropy is uncertainty available to the generator. It can come from operating-system events, hardware sources or measured physical noise. A large output is not necessarily high-entropy output: expanding a weak seed only produces more data, not more unpredictability. A timestamp may yield a 128-bit-looking sequence while an attacker who narrows the timestamp to a few seconds faces very little uncertainty. NIST discusses min-entropy, a worst-case measure, in its SP 800-90A documentation.

Robust systems gather and assess entropy, condition it, use a deterministic random-bit generator, protect its internal state and periodically reseed. They monitor source health and fail safely rather than silently falling back to a predictable source, including during early system startup.

Choosing an RNG

Requirement Recommended choice Reason
Repeatable simulation or test Ordinary PRNG with a recorded seed Reproducibility and speed matter; attackers do not.
Game randomness without an adversarial security consequence Quality PRNG Fast and easy to debug; document the algorithm and seed policy.
Password, token, key, nonce or reset link Platform or language CSPRNG Designed to resist prediction; keep outputs and state secret.
Public lottery, contest or disputed allocation Signed randomness service or documented public draw Provides provenance and verification, not merely a random-looking result.
Physical randomness specifically required Documented TRNG/HRNG Use when procurement, compliance or public trust calls for an external physical source.

Generate random values safely

Python

For simulation work, Python’s random module is appropriate:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import random
n = random.randint(1, 100)  # inclusive

For secrets, use secrets:

import secrets
n = secrets.randbelow(100) + 1  # 1 through 100
token = secrets.token_urlsafe(32)

secrets.randbelow() performs suitable range selection instead of asking you to implement a potentially biased modulo operation. Check the version-specific random documentation and secrets documentation.

Browser JavaScript

Use Web Crypto for security-sensitive browser values, not Math.random():

Rank #2
Blue Random Number Generator d10 Dice Set (Single, TENS, Hundreds, Thousands)
  • Roll A Random Number 1 to 10000!
  • 4 Dice Set (UNIT, TENS, HUNDREDS, THOUSANDS)
  • Great for Random Numbers & Loot in RPGs
  • The Dungeon Master's Friend
const array = new Uint32Array(1);
crypto.getRandomValues(array);
const value = array[0];

See Crypto.getRandomValues() and MDN’s Math.random() guidance.

Node.js

import { randomInt, randomBytes } from "node:crypto";
const n = randomInt(1, 101); // 1 through 100
const token = randomBytes(32).toString("base64url");

Here the lower bound is inclusive and the upper bound is exclusive. Confirm the convention for your installed version in the Node.js crypto documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Operating-system APIs

Prefer your platform’s standard cryptographic API. Reading /dev/urandom casually in a shell is not a universal security recipe: encoding, blocking behavior, permissions and platform differences still matter.

Fair integers, ranges and modulo bias

Define the range before writing code: inclusive [min, max], exclusive upper bound [min, max), or a decimal interval such as [0, 1). Also specify whether sampling is with or without replacement.

Modulo bias occurs when a source range is not evenly divisible by the target range. If bytes run from 0 through 255 and you calculate byte % 10, six results receive 26 source values and four receive 25, so outcomes are not uniform. Use rejection sampling or a standard-library function that implements it. Also check maximum endpoints, negative ranges, floating-point rounding and conversions of large integers through low-precision floating-point numbers.

Rank #3
10 Pieces Odd Numbered Polyhedral Dice Set D3-D25, Odd Number Dice D3, D5, D7, D9, D11, D13, D15, D17, D19, D25 for Role Playing Table Games (Amber Set)
  • ★【Odd Numbered Dice Set】- The complete 10pcs dice set fulfill all your desire for odd number dice; Each set includes one of each of: D3, D5, D7, D9, D11, D13, D15, D17, D19, D25, completed accessories to meet your game needs;
  • ★【Easy to Read and Well Balanced】- These amber dice have black numbers on each side, every number can be sit very well. We design the dice according to principle of every face of each dice has same area, and each face has same distance to dice core. The dice are well balanced and give you random number of each rolling;
  • ★【Translucent, Solid and Durable】- these dice are made of strong and quality polyresin, waterproof and wear-resistant, not easy to break and fade, with smooth surfaces, comfortable to hold, equipped with a black velvet bag for storage and guard the dice. You can impress fellow players with this upgraded translucent dice;
  • ★【Multi-functional Scene】- These dice can be used in a variety of chess and card games, RPG card games, role-playing, math teaching, providing you and your partners with more game entertainment possibilities; It is also a beautiful and surprising gift.

Selection, shuffling and weighted choices

  • One item: select uniformly from the complete, validated list.
  • Several items with replacement: an item may appear again.
  • Several items without replacement: remove each selected item before the next draw.
  • Shuffle: use a library implementation or Fisher–Yates; do not sort by random keys, which can be biased and inefficient.
  • Weighted choice: define whether weights are probabilities, relative scores or ticket counts, then validate their total and interpretation.

For a giveaway or lottery, preserve the entrant list, selection rule, randomness source, timestamp, software version and (when appropriate) a seed or signed result. A high-quality RNG cannot fix duplicated entries, omitted participants, changed inputs or incorrect weights.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Online random-number generators

An online generator is convenient for low-stakes choices, but ask who supplies the entropy, whether output is local or remote, whether requests and inputs are logged, whether results can be reproduced or verified, what happens during an outage, and whether API quotas or billing apply. Never send passwords, private keys or confidential data to a remote service merely to obtain randomness.

RANDOM.ORG says its service uses atmospheric noise and offers HTTP and JSON-RPC interfaces: HTTP API. Its Basic API documents integer, sequence, fraction, Gaussian, string, UUID and blob methods; generateIntegers accepts n from 1 through 10,000 and bounds from −1,000,000,000 through 1,000,000,000: Basic API. The service distinguishes Basic and Signed APIs; Signed output is intended for applications needing proof of authenticity and integrity, including audits, finance, games and lotteries: API dashboard.

RANDOM.ORG’s billing page says generated-value requests are billable while usage and verification methods are non-billable. Its example for a “Virtual Item Gambling” license shows a $30 monthly base cost with 30,000 included requests; that is an example tier, not universal pricing: billing details. Automated clients should not issue multiple simultaneous requests and may be blocked for noncompliance: client guidance. For most application secrets, a local operating-system CSPRNG is simpler, faster and more private than a remote atmospheric-noise service.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Testing randomness

NIST’s statistical test program includes frequency, runs, longest-run, approximate-entropy and related tests: NIST random-bit generation program. Tests can reveal certain distribution failures, but they require sufficiently large samples and can produce false positives or negatives. Passing them does not prove unpredictability, correct seeding, protected state or resistance to compromise.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
hand2mind Plastic 3/4-inch Color Number Dice (Set of 12)
  • 6 sided dice, each side is numbered 1-6
  • Sturdy plastic
  • Supports hands-on number and operations activities
  • Dice measure 3/4"
  • Set contains 3 red, 3 yellow, 3 blue, 3 green dice (Set of 12)

Common RNG mistakes

  • Using Math.random() for secrets.
  • Seeding with the current time or a predictable counter.
  • Applying % range without rejection sampling.
  • Reusing a nonce where a protocol requires uniqueness.
  • Logging tokens, seeds or generated keys.
  • Assuming a TRNG is automatically secure or fair.
  • Failing open when secure system randomness is unavailable.
  • Confusing random order with random selection.
  • Using weighted selection when requirements call for uniform selection.
  • Leaving a deterministic test seed enabled in production.
  • Using a remote API where privacy, availability or latency rules out the dependency.

Frequently Asked Questions

Are random numbers really random?

It depends on the generator and the property required. TRNGs sample physical processes; PRNGs are deterministic but can look statistically random; CSPRNGs are designed to make outputs difficult to predict.

What RNG should I use for passwords and tokens?

Use the operating system or language CSPRNG, such as Python’s secrets, browser Web Crypto or Node’s crypto module. Do not use Math.random() or an ordinary simulation PRNG.

Can random numbers be reproduced?

Ordinary PRNG sequences can be reproduced when the algorithm and seed are retained. CSPRNG outputs should not be reproducible by an attacker, while TRNG outputs generally cannot be recreated unless the draw’s evidence or signed record is preserved.

Does a TRNG guarantee security?

No. Physical origin does not guarantee unbiased output, secure conditioning, protected transport, correct health tests or fair selection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Bestseller No. 1
quEmpire Gaming Random Number Generator Dice 1-10,000,000
quEmpire Gaming Random Number Generator Dice 1-10,000,000
Roll A Random Number 1 to 10,000,000!; 7 Dice Set; Great for Random Numbers & Loot in RPGs
$17.99
Bestseller No. 2
Blue Random Number Generator d10 Dice Set (Single, TENS, Hundreds, Thousands)
Blue Random Number Generator d10 Dice Set (Single, TENS, Hundreds, Thousands)
Roll A Random Number 1 to 10000!; 4 Dice Set (UNIT, TENS, HUNDREDS, THOUSANDS); Great for Random Numbers & Loot in RPGs
$12.99
Bestseller No. 4
hand2mind Plastic 3/4-inch Color Number Dice (Set of 12)
hand2mind Plastic 3/4-inch Color Number Dice (Set of 12)
6 sided dice, each side is numbered 1-6; Sturdy plastic; Supports hands-on number and operations activities
$4.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.