Secure Random Engine

Random Prime Number Generator

Create verified random prime numbers of any digit length or binary bit size, checked right inside your browser with 100% accuracy.

For Learning & Testing Only: Even though this tool uses your browser's secure random picker (crypto.getRandomValues), do not use these numbers for real-world passwords, bank encryption, or cryptocurrency keys. Real security systems require specialized, audited hardware tools.
Presets:
Generated Random Primes (6 Digits): 100% Verified Prime
Picked using browser secure randomness
01

How Computers Build a Random Prime in Binary

How does the generator make sure a random binary number is the exact bit length you asked for—and not even? Every candidate follows a simple 3-part pattern:

1 First Bit (MSB)
? ? ? ? ? ? ? ? Random 1s and 0s
1 Last Bit (LSB)
First Bit = 1: Prevents small numbers; makes sure the number reaches the full bit size.
Last Bit = 1: Forces the number to be odd, instantly skipping half of all numbers.
02

Interactive Tool: How Many Tries Does It Take to Find a Prime?

Computers do not store giant lists of huge primes. Instead, they pick random odd numbers and check each one until they land on a prime. Enter a bit size below to see how many tries it takes on average:

Examples:
Avg Gap Size (ln 2^k) 22.18
How Common Primes Are 1 in 22 (4.51%)
Avg Odd Tries Needed ≈ 11 tries
Error Chance (40 checks) < 10⁻²⁴
For 32-bit numbers, roughly 1 out of every 22 odd numbers is prime—so the computer only needs about 11 tries on average to find one!
03

Common Prime Sizes in Computers & Tech

Standard digit counts and computer bit sizes used in programming and online security. Click any row to load it into the generator above:

Size Name Bits / Digits Number Range Example Prime Where It's Used Action
8-bit Prime 8-bit 128 – 255 251 1-byte computer scale
16-bit Prime 16-bit 32,768 – 65,535 65,521 2-byte integer limit
24-bit Prime 24-bit 8.3M – 16.7M 16,777,213 Screen color depth scale
31-bit Prime 31-bit 1.07B – 2.14B 2,147,483,647 Famous Mersenne prime (1772)
32-bit Prime 32-bit 2.14B – 4.29B 4,294,967,291 Standard 32-bit number
48-bit Prime 48-bit 140T – 281T 281,474,976,710,597 Network device ID scale
61-bit Prime 61-bit 1.15 × 10¹⁸ 2,305,843,009,213,693,951 Mersenne Prime #9
64-bit Prime 64-bit 9.22 × 10¹⁸ 18,446,744,073,709,551,557 Standard 64-bit limit
128-bit Prime 128-bit 1.70 × 10³⁸ 3.40 × 10³⁸ scale Everyday encryption key size
256-bit Prime 256-bit 5.78 × 10⁷⁷ 1.15 × 10⁷⁸ scale Bitcoin & modern security
384-bit Prime 384-bit 1.97 × 10¹¹⁵ 3.94 × 10¹¹⁵ scale High-security government size
512-bit Prime 512-bit 6.70 × 10¹⁵³ 1.34 × 10¹⁵⁴ scale Older RSA-1024 building block
1024-bit Prime 1024-bit 8.98 × 10³⁰⁷ 1.79 × 10³⁰⁸ scale Modern RSA-2048 building block
1536-bit Prime 1536-bit 1.20 × 10⁴⁶² 2.41 × 10⁴⁶² scale Strong RSA-3072 building block
2048-bit Prime 2048-bit 1.61 × 10⁶¹⁶ 3.23 × 10⁶¹⁶ scale Ultra-strong RSA-4096 piece
3-Digit Prime 3-digit 100 – 999 997 Largest 3-digit prime
6-Digit Prime 6-digit 100k – 999k 999,983 Largest 6-digit prime
9-Digit Prime 9-digit 100M – 999M 999,999,937 Largest 9-digit prime
12-Digit Prime 12-digit 100B – 999B 999,999,999,989 Largest 12-digit prime
18-Digit Prime 18-digit 10¹⁷ – 10¹⁸ 999,999,999,999,999,989 Largest 18-digit prime
04

Step-by-Step Examples

Four step-by-step examples showing how the computer picks, filters, and proves random primes:

Example 1: 16-Bit Prime Sample: 65,521

Range: 32,768 to 65,535.

Setup: First bit set to 1 (big enough), last bit set to 1 (odd). The 14 middle bits are chosen randomly.

Result: 65,521 passes all 7 prime checks in 0.02 ms.

Example 2: Skipping Non-Primes (32-Bit) Tries: ≈ 11

How Rare: About 4.5% of odd 32-bit numbers are prime.

Quick Filter: 3,421,981,717 is tested against small primes (3, 5, 7) and ruled out immediately because it divides by 7.

Found One: Trying nearby odd numbers lands on 3,421,981,747, which passes every check!

Example 3: Safe Prime (p → 2p + 1) Pair: (11, 23)

Start Prime: Pick a prime p = 11.

Double + 1: Calculate 2(11) + 1 = 23. Since 23 is also prime, 23 is a safe prime!

Why It Helps: Safe primes block clever math shortcuts that attackers try to use on security keys.

Example 4: 100% Certainty Up to 64 Bits Mistakes: Zero

Range: Every number up to 18.4 quintillion (2⁶⁴ - 1).

Proven Rule: Mathematicians proved that testing 7 fixed bases (2, 325, 9375, 28178, 450775, 9780504, and 1795265022) catches every fake prime below 2⁶⁴.

Result: 100% mathematical certainty—never a guess.

05

Safe Prime Finder (2p + 1)

A safe prime q follows the formula q = 2p + 1 where p is also prime. Click below to hunt for a random safe prime pair:

Click the button to find a safe prime pair...

Related Prime Tools

Frequently Asked Questions

How does this page pick random prime numbers?

It uses your browser's secure random number picker (crypto.getRandomValues) to choose random whole numbers of the size you selected. It ensures the number fits your exact size and is odd (skipping even numbers), then runs a fast, exact test to confirm it is 100% prime.

What is the difference between digits and bits?

Digits are regular base-10 numbers that humans read (for example, a 6-digit prime is between 100,000 and 999,999). Bits are the binary 1s and 0s computers use (for example, a 16-bit prime uses 16 binary bits and falls between 32,768 and 65,535).

Can I use these random primes for real passwords or encryption keys?

No. Even though our tool creates verified prime numbers using secure browser randomness, real-world banking and security keys need special isolated hardware and tested security software to guard against snooping attacks. This tool is made for learning, homework, coding practice, and experiments.

Why does the generator skip even numbers?

Besides the number 2, every prime number is odd. By forcing the last binary digit to be 1, every number our tool checks is automatically odd—instantly cutting the work in half.

Could the prime test ever make a mistake?

Never for any number generated here! For numbers up to 64 bits (over 18 quintillion), our Miller-Rabin check uses 7 carefully chosen test bases proven to have zero mistakes. Even for giant numbers tested with 40 random checks, the chance of a mistake is less than 1 in a septillion (10²⁴).

What is a Safe Prime and why is it useful?

A safe prime is a prime number made by doubling another prime and adding 1 (2p + 1, where both p and 2p + 1 are prime). For example, 11 is prime, and 2(11) + 1 = 23 is also prime, making 23 a safe prime. Security systems use safe primes because they do not break down into easy-to-solve smaller number patterns, blocking clever math shortcuts.

What was the ROCA bug in security cards?

In 2017, researchers discovered a major bug called ROCA in millions of smartcards. To create primes faster, those chips used a predictable shortcut pattern instead of picking truly random primes. Attackers figured out the pattern and could crack the encryption keys in just days.

Can computers prove giant primes are 100% prime without guessing?

Yes! In 1995, computer scientist Ueli Maurer shared a step-by-step recipe that builds giant primes up from smaller confirmed primes, guaranteeing the giant number is 100% prime with zero guesswork.