Locks and keys
by Chris Woodford. Last updated: March 3, 2018.
Dangerous criminals, gold bars, glittering jewels—what do they have in common? All are kept secure by locks and keys. Would the world be a happier place if no-one had invented such things? It just might be! Imagine it for a moment. Anyone could steal anything, so perhaps no-one would bother owning very much or wanting anything more. No-one would live in a fancy house with valuable belongings, swan around in a luxury car, or earn more money than they could carry in their pocket. Perhaps that would be a better world, but it's not the one we live in! In our materialist modern age, we buy stuff, earn money, and buy even more stuff. We are what we own—and the only thing standing between a lifetime of slowly accumulated, valuable possessions and instant poverty is the lock on the door. Locks, then, are pretty important things, but have you ever stopped to wonder how they work? Let's take a closer look!
Photo: A secure padlock like this has a cylinder, pin-tumbler lock inside it. Padlocks like this are generally made from hard and rustproof metals. The body (the gold-colored part) is brass (an alloy of copper and zinc) and the shackle (the loop at the top that opens and closes) is made of hardened steel, designed to stop you sawing through it.
What is a lock?
Photo: A lock isn't simply something that's opened by a key: it's a piece of compact mechanical engineering that converts the rotary (turning) motion of your hand into reciprocal (back-and-forth) motion of the bolt that locks or opens something like a door.
In the very broadest sense of the word, a lock is a device that keeps valuables safe or restricts access to something that needs protecting. A lock can hold things out (protecting homes from intruders and banks from thieves) or keep them in (holding criminals in jail or animals in zoos). Before the modern electronic age, locks were entirely mechanical and based on intricate mechanisms made from levers, wheels, gears, and cams. During the mid-20th century, locks became more sophisticated and automated and started to incorporate electrical and electronic mechanisms. But now information is valuable too and most of it is held inside hundreds of millions of computers that are all linked together through the Internet. Modern locks that protect computers are based on encryption—a way of securing information using complex mathematical processes.
How do locks work?
Most mechanical locks are fitted to things like doors and cupboards and have two physically separate parts. One part is fitted to the frame (the static part of the door) and is essentially a sturdy, metal reinforcement for a hole cut into the door itself (to prevent the locked door from being opened with brute force). The other part of the lock fits into a rectangular hole in the door (known as a mortise) and consists of a metal mechanism that moves a heavy bolt into or out from the reinforced hole. The bolt (sometimes called a deadbolt) slides from side to side when you turn a key clockwise or anticlockwise, so it has to be operated by a mechanism that can convert rotary motion (the turning key) into reciprocating motion (the sliding bolt)—something like a cam or crank. If that were all that a lock consisted of, every key would be able to open every lock. So the other essential part of a lock's mechanism is a set of fixed or moving metal pieces (wards or tumblers) that engage with slots cut into the key, ensuring only one key can rotate, turn the cam, slide the bolt, and open the door.
Animation: In a mortise lock, the key rotates and slides a bolt in and out of the door frame as it does so. Although locks like this can be very intricate and complex, I've simplified the mechanism to its absolute basics so it's easy to understand. With the door locked, the bolt (gold, 1) is extended into the mortise (hole) in the doorframe. The key (gold, 2) is in a vertical position in the lock. The bolt is held securely in place by metal levers called tumblers (3), cut to various sizes to match the notches in the key. I'm showing just two tumblers for simplicity, one red and one green, but there are usually more. The tumblers are held in place by springs (blue, 4). When you turn the key (5), each of its notches moves one of the tumblers upward (6). The red tumbler has to move further than the green one, so the key would need to have a smaller notch for the red tumbler and a bigger notch for the green one. When all the tumblers have moved out of the way, the bolt slides to the right (7) and the door can open.
Types of locks
There are several different types of locks and they all work in a slightly different way. Ward locks are the oldest and simplest. From the outside, they look like any other lock. Inside, they they have curved, jutting out pieces of metal fitted inside them (called wards) that exactly line up with the holes in a particular key. Other keys can be inserted into the lock but the wards will stop them from turning. Since they're relatively crude and fairly easy to pick, ward locks are no longer in common use, except for very low security applications.
Animation: How a combination padlock works: A padlock like this has three, four, or five rotating metal discs (gray) with small invisible holes called gates (black) cut into them. A central bar running through the middle of the lock has small notches on it that are held firm behind the discs when the lock is securely closed. When you select the correct combination (in this case, 3-1-7-0), the gates line up with the notches in the central bar. A spring (blue) at the end of the lock pushes the bar out, the notches slide through the open gates, and the lock opens.
Tumbler locks are a more recent (19th-century), more sophisticated, and much more secure design—best known to most of us in the form of the cylindrical pin tumbler or Yale lock (invented by Linus Yale, Jr. in the 1860s). All kinds of variations on this basic design exist; if you search the US Patent and Trademark Office database for "cylinder lock," you'll find well over 500 different ones! Padlocks operated by keys are essentially portable, miniaturized Yale locks with super-small cylinders and pin tumblers. Read more about Yale locks in the box down below. Combination padlocks work in a slightly different way, as the animation here explains.
Electronic locks do away with metal keys altogether; you've almost certainly use one if you've stayed in a hotel recently. Instead of a key, you have a plastic card (similar to a credit card) that has a magnetic strip on the back. When you slide the card into the lock, an electronic reader circuit decodes the information on the strip and checks for a match with a code stored inside it. If it's the right key, the circuit activates a powerful electromagnet that pulls a bolt sideways, allowing you to open the door.
Photo: Electronic key: Some banks are now giving two-factor authentication devices like this to their customers. When you put your credit or debit card into it, it generates a number that you type into a banking or shopping website to use as a kind of one-off, disposable password. So it's a bit like an electronic key that opens an online lock.
With traditional mechanical and electronic locks, there's still one basic security flaw: if someone else has your key, they can open your lock and steal your things. That's why the latest forms of security incorporate biometric locks (featuring things like fingerprint readers or iris scanners) that grant access to a specific person rather than just any old person who happens to have the matching key. Sooner or later, sometime in the future, almost every lock we encounter will have some form of biometric security checking built in.
If you're using a computer, a password (or passphrase) is the equivalent of a key granting you access to a particular machine, network, website, or whatever it might be. Just as a key can be stolen, so can a password—but the added problem with passwords is that they can be guessed (or different ones can be tried again and again until the right one finally works). That's why really secure computer systems (such as online banking systems) are now using a kind of enhanced security called two-factor authentication: to gain access, you have to know one or more passwords and possess a physical device (called a token) that generates a one-off (disposable) security code you enter as a kind of extra password. Read more in our article on security tokens.