Cryptography & Security
Intermediate

Key Space Size

Number of possible keys for a b-bit key.

Formula

K=2bK = 2^b

Live Calculator

Members

Variables

KNumber of keys
bKey length (bits)

Example

128-bit key: K = 2^128 ≈ 3.4×10³⁸

How it works

A binary key of length b has two choices for each bit: 0 or 1. Because these choices are independent, the total number of distinct keys is 2 multiplied by itself b times, which gives 2^b. This is the size of the key space, and it matters because a larger key space makes exhaustive brute-force search much harder.

When to use it

Use this formula when you want to estimate how many different keys, passwords, or secret bit patterns are possible for a given binary length. It is especially useful in cryptography, security auditing, and comparing how resistant different key sizes are to brute-force attacks.

Worked example, step by step

Suppose a system uses a 56-bit key. K = 2^b K = 2^56 K = 72,057,594,037,927,936 So the key space contains about 7.2 × 10^16 possible keys.

Common mistakes to avoid

  • Forgetting that each bit has two possible values, not 10 or 256
  • Confusing key length in bits with key size in bytes
  • Assuming a larger key space always guarantees practical security without considering weak algorithms or implementation flaws

Did You Know?

AES-128 has more possible keys than there are atoms in a million Earths — brute force is hopeless.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026