DEV Community

Lucian (LKB)
Lucian (LKB)

Posted on Originally published at lkforge.com

How Long Would It Take to Crack Your Password?

The strength of a randomly generated password is one number — its entropy, in bits
— and it comes from a single line of arithmetic. I computed it across every length and
character-set choice using the exact character sets our password
generator
ships, then turned each into
a crack time. One thing comes out very clearly: eight characters is no longer enough,
and length matters far more than sprinkling in symbols.

Strength is one number: entropy

When a password is generated randomly, its unpredictability is exactly length ×
log2(pool size)
, where the pool is how many characters could sit at each position. With
all four types on — lowercase, uppercase, digits and symbols — the generator draws from
an 88-character pool. Each extra bit of entropy doubles the number of guesses an
attacker must make, so this one number decides everything.

Crack time, by length

Entropy becomes a time once you assume a guessing rate. Below, every password uses all
four character types. Offline assumes a GPU rig managing ~1 trillion guesses a second
against a fast or unsalted hash — the worst realistic case if a site's password database
leaks. Times are for the average attack, which searches half the space.

Length Entropy Rating Offline (10¹²/s)
6 38.8 bits Weak instant
8 51.7 bits Fair ~30 minutes
10 64.6 bits Strong ~5 months
12 77.5 bits Strong ~3,400 years
14 90.4 bits Very strong ~2.6×10⁷ years
16 103.4 bits Very strong ~2.0×10¹¹ years
20 129.2 bits Very strong ~1.2×10¹⁹ years

The cliff is between 8 and 12. An 8-character password is a coffee break; a 12-character
one is thousands of years; by 16 the numbers stop meaning anything human. That is the
whole case for a password manager: you never type these, so there is no reason not to
make them 20 characters of noise.

Length beats complexity

The instinct to reach for ! and $ is right, but weaker than the instinct to add
characters. Turning on symbols multiplies the pool once. Adding a character multiplies
the difficulty again at every position. The proof is blunt: an 11-character
lowercase-only
password already has more entropy than an 8-character password using
all four types
(51.7 bits). A 16-character lowercase-only password holds 75.2 bits —
well past "strong" — from an alphabet of just 26 letters.

So if you have to choose, choose length, then add the other types on top because there's
no reason not to. Using all four types, you cross 40 bits at 7 characters, 60 at 10, and
80 — comfortably "very strong" — at 13.

The one caveat

All of this assumes the password is randomly generated. A human-chosen "P@ssw0rd!"
has nowhere near the entropy its length and character variety suggest, because attackers
guess predictable substitutions first. The formula is only honest for passwords a machine
picked at random — which is exactly what a generator is for.

Reproduce it

const entropy = (length, pool) => length * Math.log2(pool)     // pool = 88, all four types
const crackSeconds = (bits, rate) => 2 ** (bits - 1) / rate    // average attack
// entropy(8, 88) = 51.7 bits  ->  crackSeconds(51.7, 1e12) ≈ 30 minutes
Enter fullscreen mode Exit fullscreen mode

Full write-up, chart and the live password
generator
(it shows the entropy as you
type):
How Long Would It Take to Crack Your Password?.

Originally published on LK Forge.

Top comments (1)

Collapse
 
carmenelena_226f2d profile image
carmen-elena

Really useful way to visualize password security. I especially like the “length beats complexity” point—it's much easier to understand when you see 8 characters versus 12 or 16 translated into actual cracking time. The caveat about human-generated passwords is probably the most important part too: complexity on the surface doesn't equal entropy. Good practical reminder to let a password manager generate long, random passwords instead of trying to invent “complex” ones ourselves