17Technology

How a lock works

A lock holds a bolt in place with parts that only the right key moves out of the way. Four benches take you from a wooden peg lock to the brass pins in most door locks today.

Open the shop

From a wooden peg to a brass pin

A lock holds a bolt in place with parts that only the right key moves out of the way. That idea is very old. The four benches below start with a lock made of wood and end with the pins in most door locks today.

Each bench has a lock you can try. These are toy versions made for this page. Without a script, each bench shows one picture and its numbers.

Bench one

The wooden peg lock

One of the oldest kinds of lock is made of wood. A bolt on the door has holes in it. Loose pegs sit above the holes and drop into them, so the bolt cannot slide. The key is a wooden bar with upright prongs. Push it in and each prong lifts one peg out of its hole.

Try three keys. Only a key with the right number of prongs, the right distance apart, lifts all the pegs at once.

Key A has three prongs, spaced like the three holes. All three pegs are lifted, so the bolt can slide.

Bench two

Pins and the shear line

Most door locks today use the same idea with metal pins. A round plug sits inside a housing and turns when you turn the key. Pins stand in holes that cross the gap between the plug and the housing. That gap is called the shear line. Springs push the pins down, so in a locked lock the pins stop the plug from turning.

Each hole holds two pins: a key pin at the bottom and a driver pin above it. The cuts of the right key lift each pair by exactly the right amount, so the gap between the two pins sits on the shear line. Push a key in and watch the pins ride its cuts.

shear line

Key A is the right key. Every pair of pins splits exactly at the shear line, so the plug is free to turn.

Bench three

Cut your own key

Each cut on a key has a depth from 0 to 9. A deeper cut needs a longer key pin to reach the shear line. Change the cuts below. A pin that does not split at the shear line stops the plug. Here you can see the pins, but in a real lock they are hidden inside.

Being close is not enough. One cut that is a single step too deep or too shallow is enough to block the lock.

shear line
Cut 13
Cut 26
Cut 32
Cut 47
Cut 55

This key has cuts 3, 6, 2, 7 and 5. Four pairs of pins split at the shear line. The last driver pin reaches into the plug, so the plug cannot turn.

Bench four

How many keys

Each pin can have any of the depths, so the number of different keys is the number of depths multiplied by itself once for each pin. Five pins with ten depths make 10 × 10 × 10 × 10 × 10 = 100,000 keys.

Makers also limit how different two neighbouring cuts may be, so a key does not get a steep cliff that would wear or break. That removes some of the keys. Change the number of pins, the depths and the limit.

Number of possible keys for different numbers of pins and depths
Pins4 depths6 depths10 depths
3 pins642161,000
4 pins2561,29610,000
5 pins1,0247,776100,000
6 pins4,09646,6561,000,000
7 pins16,384279,93610,000,000

Five pins with ten depths make 100,000 keys. Allowing any neighbouring cuts leaves all of them.

Key takeaways

  1. A lock holds a bolt or plug in place with parts that only the right key moves out of the way.
  2. In a wooden peg lock, prongs on the key lift loose pegs out of holes in the bolt. The prongs must be the right number and the right distance apart.
  3. In a pin lock, springs push pairs of pins across the shear line. The right key lifts each pair by exactly the right amount, so the gap between its two pins sits on the shear line.
  4. One pin that is a single step off is enough to block the plug.
  5. The number of possible keys is the number of depths to the power of the number of pins. Five pins and ten depths make 100,000, and fewer when neighbouring cuts are limited.

Sources

Most of these sites could not be opened while this page was written, so the facts were checked through search results that quote them. The wooden peg lock with a key that lifts pegs and the age of about 4,000 years at Khorsabad, the pin, spring, shear line and key pin and driver pin parts, Linus Yale Jr. and a small flat key in the 1860s, and the number of keys as depths to the power of pins each appeared in at least two places. The sources disagree on the Yale dates (1848 for his father, 1861 and 1865 for the son), so only the 1860s are given, and scholars question which find is the oldest lock. The key count with a limit on neighbouring cuts was checked by counting every key one by one. The locks on this page are toy models made for this page.