Keyspace Size Calculator: K = R^L Possible Keys and Bits

Keyspace Size Calculator

Find the keyspace K = R^L, the total number of possible keys or passwords, from an alphabet size R and a length L. See the equivalent bit strength log2(K), the exact number of decimal digits in K, and how that number stacks up against tangible magnitudes like grains of sand and atoms in the universe.

🔑Real Key Configuration Presets

📝Keyspace Inputs

R is how many distinct symbols each position can hold.

Used only when the dropdown above is set to Custom.

Number of characters, digits, or bits in the key.

Controls the mantissa shown in scientific notation.

Turn on to see how many times larger one keyspace is.

Second configuration, only used in compare mode.

Length of the second key for the side-by-side ratio.

Tool reports the length L config A needs to hit this.

Keyspace K = R^L 0 possible keys, scientific notation
Equivalent bit strength 0 bits log2(K) = L x log2(R)
Decimal digits in K 0 digits when K is written out
Magnitude comparison -- nearest tangible reference

🔢Formula Snapshot

KR ^ L
bitsL × log2 R
digitsfloor(L log10 R)+1
ratioKa / Kb

🔑Character Set Sizes Reference

Character SetAlphabet RBits per SymbolExample Symbols
Binary21.000 1
Octal83.000-7
Decimal digits103.320-9
Hexadecimal164.000-9 a-f
Lowercase letters264.70a-z
Base32325.00A-Z 2-7
Mixed-case letters525.70a-z A-Z
Alphanumeric625.95a-z A-Z 0-9
Base64646.00letters + / =
Full ASCII printable956.57all keyboard
Extended byte2568.00full byte

🌐Real-World Magnitude Reference

Reference QuantityApprox CountApprox BitsComparable Key
Seconds since Big Bang4.4e1758 bitsDES 56-bit
Grains of sand on Earth7.5e1863 bits11 alnum chars
Stars in the universe1e2480 bitsHex 20 chars
Atoms in a human body7e2793 bits16 alnum chars
Atoms in planet Earth1.3e50166 bitsASCII 26 chars
Atoms in the Sun1.2e57190 bitsHex 48 chars
Atoms in the Milky Way1e69229 bitsASCII 36 chars
Atoms in the universe1e80266 bitsAES-256 key

📊Keyspace by Length and Alphabet Comparison Grid

Length LBinary R=2Digits R=10Hex R=16Lower R=26Alnum R=62ASCII R=95
44 bits13.3 bits16 bits18.8 bits23.8 bits26.3 bits
66 bits19.9 bits24 bits28.2 bits35.7 bits39.4 bits
88 bits26.6 bits32 bits37.6 bits47.6 bits52.6 bits
1010 bits33.2 bits40 bits47.0 bits59.5 bits65.7 bits
1212 bits39.9 bits48 bits56.4 bits71.5 bits78.8 bits
1616 bits53.2 bits64 bits75.2 bits95.3 bits105 bits
2020 bits66.4 bits80 bits94.0 bits119 bits131 bits
2424 bits79.7 bits96 bits113 bits143 bits158 bits
3232 bits106 bits128 bits150 bits190 bits210 bits

🔑Common Key Configurations

ConfigurationR x LKeyspace KBitsDigits
4-digit PIN10^41.0e413.35
6-digit OTP10^61.0e619.97
8 lowercase26^82.1e1137.612
DES 56-bit2^567.2e165617
12-char alnum62^123.2e2171.522
16-char alnum62^164.8e2895.329
AES-128 / Hex 322^1283.4e3812839
Full ASCII 2095^203.6e3913140
AES-256 / Hex 642^2561.2e7725678

Formula Breakdown

Keyspace K = R^LEach of the L positions is chosen from R symbols independently, so the total count multiplies out to R multiplied by itself L times.
Example K = 10^6A 6-digit code uses R = 10 and L = 6, giving K = 10^6 = 1,000,000 possible codes, exactly one million.
Bits = L × log2(R)The bit strength is log2(K). For R = 10, L = 6 that is 6 × 3.3219 = 19.93 bits of entropy.
Digits = floor(L × log10 R) + 1The number of decimal digits in K. For 10^6 that is floor(6) + 1 = 7 digits, since one million is written 1000000.
Scientific K = 10^(L log10 R)Writing the exponent base ten keeps huge keyspaces readable, so 62^12 becomes about 3.226e21 rather than a 22-digit string.
Ratio = Ka / KbHow many times larger one keyspace is equals R_a^L_a divided by R_b^L_b, best read as a difference in bits.
Each +1 symbolAdding one character multiplies K by R and adds log2(R) bits, so length grows strength far faster than a slightly bigger alphabet.

💡Keyspace Sizing Tips

Length beats alphabet: Going from 8 to 12 alphanumeric characters lifts a keyspace from about 47.6 bits to 71.5 bits, a jump of roughly 23.8 bits, which multiplies K by about 15 million. Switching the same 8-character key from lowercase to full ASCII only adds about 15 bits. When you need a bigger keyspace, add symbols before you expand the character set.
Match the reference, not the myth: A keyspace near 63 bits, such as 11 alphanumeric characters, roughly equals the grains of sand on Earth at 7.5e18. To exceed the estimated 1e80 atoms in the observable universe you need about 266 bits, which is why a 256-bit AES key at 1.2e77 is considered comfortably beyond any exhaustive search of every possible key.

It’s a single clean question: How many unique passwords or keys are possible using a certain design? That’s the keyspace, the answer to that question, and it’s the base for all talk about cryptographic strength. The equation is precise and straightforward: K = R^L, where K is the keyspace (the number of unique combinations), R is the size of alphabet (the number of unique symbols each character can contain) and L is length (how many characters).

With this, it calculates that number and its equivalent in bits. It also finds the number of decimal digits it will contain and how big that huge number realy is compared to something we can understand, like atoms and grains of sand. It takes mathematical abstraction and makes it concrete.

How to Calculate Your Keyspace Size

Think about creating that key position by position: For example, suppose it has L positions, where each can be one of R different symbols. Then the first position can be any of those R symbols; the second can be any of those R symbols; etc., right? And they’re all independent choices, so you just multiply them together. You get R times R times … times R (L times).

Ten possible digits in a four-position PIN gives us ten times ten times ten times ten, a ten-thousand-combo keyspace. Six digits in a one-time code gives you one million. Keyspace means the full set of possible keys, and it is simply the size of the space you have to search.

Cryptographers don’t work with raw keyspaces; those become astronomically large very quickly, and we measure them in bits instead. K = R^L. Taking the base-two logarithm of this number gives you its bit strength, which factors out nicely: the bit strength = L * log2(R).

How many bits does each symbol provide? It provides one bit per binary digit, 3.32 bits per decimal digit, four bits per hex character, and approximately 6.57 bits per full-ASCII character. Bits are handy in that they (1) double the keyspace for each additional bit, and (2) add up linearly.

Thus when someone says “128-bit” key, they’re referring to something that might be literal 128 binary digits long, or maybe only about 20 full-ASCII characters long; but either way its keyspace is 2^128. Why do people speak in terms of bits? Because bits are handy.

The calculator will show four numbers about your setup. Because it’s impractical to spell out a keyspace that has dozens of digits, the first card displays the entire count as a number in scientific notation. The second card converts that to bits and shows you its equivalent bit strength… The number quoted most often in security circles.

The third card breaks down how many decimal digits are part of that count: it’s floor(log10()) plus one. If you wanted to write out every digit in the whole number, you’d know exactly how long that is. The fourth card takes that keyspace and turns it into a real world measure, assigning a name to the next-larger physical quantity so you can visualize this abstract exponent.

Hit compare mode and you can put them side-by-side. Now comes the important lesson: The keyspace increases much faster with length than with width. An eight character alphanumeric key gains around 23.8 bits if we expand it to twelve characters, multiplying its keyspace by approximately fifteen-million. That’s almost double the length of the key!

Compare that with converting the exact same eight character key from lower case to all ASCII, which only adds ~15 bits. Length is the big winner; that’s why long passphrases trump short but complex passwords. Most people think to tack in symbols. They should of been thinking to tack in length.

These numbers get incredibly large very quickly, but it’s hard to see that as an exponent. This calculator ties the size of bits to physical references for scale. There are approximately 63 bits worth of grains of sand on earth. There are approximately 80 bits worth of stars in the universe. There are about 166 bits worth of atoms on planet Earth. About 266 bits (on the order of) worth of atoms in the observable universe.

These markers illustrate how far short you’ll fall before getting to the size of even moddern ciphers, there is no hope of trying all possible keys on a laptop because it would be physically impossible. Brute forcing a universe sized keyspace? Not gonna happen.

Its preset settings reflect actual crypto history. A 56-bit key for DES could be searched by current computing machines and was eventually retired. A 128-bit keyspace (AES-128) is equal to around 3.4e38 keys; a 39 digit number beyond the reach of any imaginable computer. With 256 bits (AES-256), we’re at around 1.2e77, or 78 digits, still dwarfed by the amount of atoms in the observable universe (and just below).

For anyone interested, a string of 32 characters in hex format is equal to same 128-bit keyspace of AES-128: 16^32 = 2^128. This tool demonstrates this nice coincidence well. And that’s it! That is where knowing your keyspace begins; it doesn’t end there.

The goal here is to force you to see the plain raw size of your keyspace first, before adding in crack times or attacker speeds or anything else. If you’re going to have security based off keys, a large keyspace is necessary, but it’s only meaningful if keys are picked from that space uniformly at random.

Use these as reference tables to know your token sizes and API key sizes with confidence. Also, remember how huge a good keyspace should feel from the magnitude comparisons alone.

Keyspace Size Calculator: K = R^L Possible Keys and Bits