Lots of keys slide into your front door lock. Only one of them turns it. Even a key with four of its five notches right will not move it. So how does the lock tell them apart?

Inside, there are little stacks of pins, one stack for every notch, or cut, on the key.

Yale's lock

Pin locks are old. In 1865, an American named Linus Yale Junior got a patent for a better one. It had a thin, flat key, and many front doors still use locks like his.

Each stack is two pins, one on top of the other. The key has to lift every stack, so the places where the pins meet all land on one line. That is the line between the part that turns and the part fixed to the door.

Guess

Guess

Picture a key that is exactly right on four of its five cuts. You put it in and turn. Does it: A, turn a little, then stop; B, turn but feel stiff; or C, not turn at all? Pick one now.

A jigsaw piece?

Many people picture a key like a jigsaw piece. The lock has a hole of the same shape, and only the right key fits it. When you turn the key, they picture it pushing the bolt, the metal bar that holds the door shut.

But think about a wrong key. If it is made for the same kind of lock, it slides all the way in. The keyhole only checks the shape of the key's sides, so it cannot be what tells the keys apart. Something inside checks the cuts along the top edge of the key.

The parts

The shell, the plug and the pin stacks, cut open
2:22 ↗The shell, the plug and the pin stacks, cut open

The outer part is the shell. It is fixed to the door and never moves. Inside it is a round part called the plug. The key goes into the plug, and the plug is what turns.

Where the plug meets the shell, there is a line. Locksmiths call it the shear line. Five holes cross that line, one above each cut of the key. Each hole holds a stack: a bottom pin, a top pin, and a spring that pushes them down.

No key

Take the key out, and the springs push every stack down as far as it goes. Each top pin hangs down past the line. Part of it is in the shell, and part is in the plug. Try to turn the plug, and it cannot move.

Key idea

The plug can't turn while any pin crosses the line.

The key

Hills and valleys on the key lift each stack
3:37 ↗Hills and valleys on the key lift each stack

So how does the right key fix that? Its edge has hills and valleys. As the key slides in, each stack rides up a hill and down into a valley, and rests there. Each valley is called a cut.

A shallow cut lifts its stack high. A deep cut lets it sit low. On a Schlage lock, a cut can have one of ten depths. Each step is less than half a millimetre.

On the line

Every gap between the bottom and top pins sits on the line
4:07 ↗Every gap between the bottom and top pins sits on the line

With the right key, every gap sits exactly on the line. Now nothing crosses the line. The bottom pins are all in the plug, and the top pins are all in the shell. So the plug can turn, and the bottom pins turn with it.

Key idea

The right key lifts every gap to the line, all at once.

That is the line Yale's patent talks about: the dividing line between the two parts of each pin, all in one line. And how does turning open the door? A bar on the back of the plug turns with it, and the bar pulls the bolt into the door. The key never touches the bolt.

Nearly right

Back to the guess. This key is right on four cuts. Only the second cut is too shallow. Surely four out of five gets you most of the way?

Turn it, and it does not move at all. The second cut lifts its stack too high, so the bottom pin pokes up past the line, into the shell. That one pin holds the plug, just like the top pins did. So the answer to the guess is C.

Five numbers

Here is a check. This time the third cut is too deep. Which pin stops the plug: the bottom pin, poking up, or the top pin, hanging down? Or neither?

The answer is the top pin. A deep cut lets the stack sit too low, so the top pin hangs down into the plug. Either way, a pin crosses the line.

Key idea

The lock checks each cut on its own, and every one must be right.

So the cuts on a key are really just five numbers, one depth for each cut.

Master key

So each lock opens for one key. But in a school or an office, one key can open every door. The answer is one more small part. In some stacks, a thin extra pin sits between the bottom pin and the top pin. It is called a master pin.

Now that stack has two gaps, not one. Your own key lifts it so that one gap sits on the line. The master key lifts it to a different height, so the other gap sits on the line. A thin extra pin gives a stack two gaps, so two heights work.

The cost

Every extra gap is one more height that opens the lock. So a lock with master pins can be easier to pick. A security researcher, Matt Blaze, showed something worse. With one of those locks, its own key, a few blank keys and a file, someone could make a working master key.

Try it

Try it

Use only your own keys and locks. Lay two house keys for the same kind of lock side by side, so the cuts start at the same place. Find where they differ.

At the place where the two keys differ, one key has a deeper valley than the other. That one difference is enough to make them open different locks.

On a Schlage lock with five cuts, each cut has ten depths. That is a hundred thousand patterns, in theory. Some are not allowed, because cuts next to each other cannot be too different, so that leaves at most about eighty thousand.

Do not post a clear photo of your key online. In 2008, researchers in San Diego showed that a key can be copied from a photo. Its five numbers are right there on its edge.

In one breath

A lock does not read the whole shape of your key. Past the slot, it checks five numbers, one stack at a time, and every gap must sit on the line. A thin master pin gives a stack two gaps, so two heights work, and that is how one master key can open many doors.