Key Length to Keyspace Calculator
A key length is compact to write, but its security scale is easy to underestimate because every additional bit doubles the number of possible keys.
Run — free
This calculator converts any supported bit length into the exact size of its keyspace and the average number of attempts required by an ideal exhaustive search. It also places the result beside 56-, 128-, and 256-bit reference strengths, making differences visible as exact powers of two rather than vague labels. The calculation is deterministic and assumes uniformly distributed keys with no shortcut attack against the underlying cryptographic system.
From a bit length to the number of possible keys
A key with n bits can represent two raised to the power n distinct bit patterns. That simple rule produces numbers that grow far faster than ordinary intuition. Adding one bit doubles the keyspace; adding ten bits multiplies it by 1,024. The calculator performs this exponentiation with exact integer arithmetic and returns the full decimal value, not a floating-point approximation. It also provides a compact scientific-notation form for quick reading. For example, a 56-bit key has 72,057,594,037,927,936 possible values, while a 128-bit key has 340,282,366,920,938,463,463,374,607,431,768,211,456. Those totals describe the size of the search space only. They do not prove that an algorithm is secure, because implementation defects, weak key generation, leaked state, cryptanalytic attacks, or protocol mistakes may reduce the real work dramatically. Use the result to understand keyspace magnitude, then evaluate the cipher, mode, protocol, and key-generation process separately.
Understanding average brute-force effort
An exhaustive search tries candidate keys until it finds the right one. If the correct key is uniformly distributed and candidates are tested without useful information about its location, it may appear anywhere in the search order. The expected position is halfway through the keyspace, so the calculator reports two raised to the power n minus one as the average number of attempts. This is an expectation, not a guarantee: a particular search could succeed on its first attempt or require nearly every possible key. The output deliberately reports attempts rather than a cracking time. Converting attempts into seconds requires a defensible test rate for the exact algorithm, hardware, parallel strategy, and verification workload. A guess rate borrowed from a different cipher or password hash can mislead by many orders of magnitude. The average-attempt figure is therefore the stable mathematical quantity, suitable for comparing strengths without pretending that every cryptographic target can be tested at the same speed.
Comparing 56-, 128-, and 256-bit strengths
The comparison records express the selected length relative to three familiar reference points. Fifty-six bits represents a historically important but now small exhaustive-search space. One hundred twenty-eight bits is vastly larger: its keyspace is two raised to the power 72 times the 56-bit space. Two hundred fifty-six bits expands the space by another factor of two raised to the power 128 over 128 bits. When your selected length is above a reference, the result labels it stronger and gives the exact multiplication factor. When it is below, the result labels it weaker and gives the reciprocal divisor, avoiding imprecise fractional arithmetic. Equal lengths are marked directly. These comparisons concern brute-force keyspace only; they do not claim equivalent security across unrelated primitives. A 256-bit key does not automatically deliver 256 bits of effective security if the construction has a lower security bound, if quantum search is in scope, or if keys come from a biased or low-entropy source.
What you can do with it
Review a cryptographic design
Turn a proposed key length into exact keyspace and expected-search figures before comparing it with the design's stated security target.
Explain exponential growth
Show students or stakeholders why a modest increase in bits produces an enormous multiplication in exhaustive-search effort.
Check legacy and modern strengths
Place a custom or legacy key size beside the fixed 56-, 128-, and 256-bit reference points using exact powers of two.
FAQ
How is the number of possible keys calculated?
For a key length of n bits, the number of possible bit patterns is exactly 2^n.
Why is average brute-force effort half the keyspace?
With a uniformly distributed correct key and no search shortcut, its expected position in an exhaustive ordering is halfway through the possible keys.
Does a larger key always make a system secure?
No. Key length measures one brute-force bound. Algorithm weaknesses, implementation flaws, poor randomness, protocol errors, and key exposure can dominate real security.
Why does the calculator not estimate years to crack?
Time depends on the exact algorithm, verification cost, hardware, parallelism, and attacker model. Attempts are the deterministic comparison that does not assume an arbitrary guess rate.
What do stronger and weaker mean in the comparison?
They describe only the ratio between exhaustive keyspaces. A difference of d bits corresponds to a factor of 2^d.
What does the API request cost?
Each API request costs $0.002. The same deterministic calculation can run in the browser as a Tier A capability.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/dev/key-space-bits \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"key_bits":128}'const res = await fetch("https://api.kit.forhosting.com/dev/key-space-bits", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"key_bits": 128
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/dev/key-space-bits",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"key_bits": 128
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/dev/key-space-bits", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"key_bits":128}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"key_bits":128}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/dev/key-space-bits", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"key_bits": 128
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "dev.key_space_bits",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_bits | 4096 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |