# Door and Bomb Codes

## From the Book

Five minutes later, the bus dropped them at the entrance to Will’s street. Nestled in the bushland at the end of the cul-de-sac, Jeff’s modern brick house was a hundred metres from the nearest neighbours, but with the vegetation, it might as well have been kilometres.

The front door had a high-tech electronic keypad next to it. Will punched a sequence in.

“Eight-digit passcode,” said Will, as the door chimed. “Take you weeks to try every combination.”

“What are you, a piano virtuoso?” Eliza said. “More like a year.”

(and then later in the book…)

Drake shook his head. “No point. This’ll take out half the city, and irradiate the rest. We’re not getting anyone far enough away in five minutes.”

“Then you disarm it!” Will’s voice cracked.

“There’s a passcode input,” Drake said, frowning at the display, which now read *4:54…* *4:53. *Will tore his eyes away.

“It’s a four digit code,” Eliza whispered. “There’s ten thousand combinations. You’ll never get close.”

## The Problem

The duo encounter several code-breaking situations in the book, either in passing or in a critical life and death situation. The first is the security code for the front door of Jeff’s house, which has an 8 digit code.

Now 4 digit codes on cheap bike locks and suitcases are notorious for being quite breakable by someone patient enough to sit there and try all the combinations. But how long would it take to brute force (try every combination) an 8 digit code?

## The Calculation

There are 10 different numbers possible for each digit in the code: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. A one digit code would have only 10 possible combinations. A two digit code would have 10 * 10 = 100 possible combinations. For an 8 digit code:

So how long does it take to enter one combination? Let’ say about 5 seconds in total to enter the numbers and wait for the security system to decide. Then:

This is more than 15 years!

## Bridge Bomb Code

Later they encounter a 4 digit code on the 100 tonne dirty bomb at the Goodwill Bridge. Eliza does a quick mental calculation and works out it’s unlikely they’ll be able to brute force the code in the 5 minutes they have remaining:

Let’s say he can enter a code every 3 seconds:

So it could take them up to 500 minutes, but they’ve only got five minutes. It’s highly unlikely they’ll be able to brute force the correct combination before the bomb explodes.

## Real Life Example – Passwords Today

Most passwords nowadays can include lower and upper case letters, symbols and numbers – all 95 printable ASCII characters.

This large number of possible characters means brute forcing an 8 character password is much more challenging:

That’s more than 6 quadrillion possible combinations – too many to do by hand and you’d need a quite fast computer to crack it. However this doesn’t necessarily stop people. A lot of passwords have known phrases and are complete words (reducing the number of possible combinations). There is a really good youtube video about this. You may even want to change some passwords after watching it.

## Notes

The above examples should strictly speaking all be called *permutations*, rather than *combinations*, because the ** order** of the digits matters. Let’s say I had a 2 character password for my front door which read “5B”. If I entered “B5” the door wouldn’t open, because I’d entered the characters in the wrong order. Situations where the order matters are called

*permutations*.

A good example of *combinations* are lottery numbers – for most lotteries, as long as you have the right numbers, it usually doesn’t matter what order they’re drawn in.