# 鎖是怎麼運作的：為什麼只有你的鑰匙能轉開它

> 彈子鎖要打開，鎖芯就得轉動，而橫跨剪切線的一組組彈子擋住了它。鑰匙上的每道齒把每組彈子抬到各自的高度；只有對的那把，才能讓每個分界都落在線上。理論上最多 10 萬種鑰匙，還有總鑰匙為什麼也能開。一支 49 秒的科普短片，每個數字都有出處。

- URL: https://oliverz.dev/zh-hant/videos/lock-and-key
- Author: Oliver Zhang (https://oliverz.dev)
- Language: zh-Hant
- Published: 2026-11-03
- Tags: locks, how-it-works, explainer
- Video: https://www.youtube.com/shorts/ZvY2vcihcAs

> **一句話總結：** 彈子鎖裡，鎖芯裝在鎖殼裡面，要開鎖，鎖芯就得轉動。兩者之間的那條線叫剪切線，大約五組彈子橫跨著它：每組是一顆下彈子、一顆上彈子和一根彈簧。沒插鑰匙時，彈簧把上彈子推過這條線，鎖芯就被卡死。鑰匙上的齒把每組彈子抬到各自的高度，只有對的鑰匙，才能讓每組下彈子和上彈子之間的分界恰好落在線上。哪道齒深了或淺了一點，就仍有一顆彈子擋著。五顆彈子、十種深度，理論上最多能做出 10 萬種鑰匙；總鑰匙能開，是因為一顆中間彈子讓那組彈子多了第二個分界。

## 一個必須轉動的鎖芯

Wikipedia 談彈子鎖（pin tumbler lock）：「In this type of lock, an outer casing has a cylindrical hole in which the plug is housed. To open the lock, the plug must rotate.」（在這種鎖裡，外殼上有一個圓柱形的孔，鎖芯就裝在裡面。要開鎖，鎖芯必須轉動。）Lockwiki：「The plug is the inner piece of the lock that rotates upon insertion and tension of the correct key.」（鎖芯是鎖的內部零件，插入正確的鑰匙並施加扭力時會轉動。）

The Engineering Mindset 替兩者之間的那條線取了名字：「The intersection between the plug and the lock housing is known as the shear line.」（鎖芯與鎖殼的交界處稱為剪切線。）

## 橫跨剪切線的彈子

鎖芯和鎖殼上都鑽了孔。Wikipedia：「A series of holes, typically five or six of them, are drilled vertically into the plug.」（鎖芯上垂直鑽有一排孔，通常是五個或六個。）（我們的圖裡畫了五個。）孔裡裝著「key pins of various lengths, which are rounded to permit the key to slide over them easily」（長短不一的下彈子，頭部是圓的，好讓鑰匙輕鬆滑過），還有「Above each key pin is one or more spring-loaded driver pins.」（每顆下彈子上方，是一顆或多顆裝有彈簧的上彈子。）The Engineering Mindset：「Within each chamber we find a spring which pushes another pin, known as a driver pin.」（每個孔腔裡都有一根彈簧，推著另一顆彈子，叫作上彈子。）

## 沒有鑰匙：卡死

Wikipedia：「When the plug and outer casing are assembled, the pins are pushed down into the plug by the springs.」（鎖芯和外殼組裝好後，彈簧會把彈子往下推進鎖芯。）還有：「When the key is not in the lock, the pins straddle the shear point, preventing the plug from rotating.」（鑰匙不在鎖裡時，彈子橫跨剪切點，讓鎖芯無法轉動。）

The Engineering Mindset：「With no key inserted, the driver pins sit part way in the housing chamber and part way within the plug. This means the plug is unable to rotate.」（沒插鑰匙時，上彈子一部分在鎖殼的孔腔裡，一部分在鎖芯裡。這表示鎖芯無法轉動。）

## 每道齒，各有高度

鑰匙就是一排高度。The Engineering Mindset：「Each key pin is a different height, and this will correspond to the profile of the key.」（每顆下彈子的高度都不同，與鑰匙的輪廓一一對應。）Lockwiki：「Key pins are sized differently corresponding to the different depth cuts on the key.」（下彈子長短不一，對應鑰匙上不同深度的齒。）這些深度就是鑰匙的齒形（bitting），也就是「the depth of key cuts on a cylinder key for a pin tumbler lock, often expressed as a number」（彈子鎖圓柱鑰匙上齒的深度，常用數字表示）（Wikipedia）。我們範例裡的鑰匙，齒形是 2-6-4-8-3。

## 對的鑰匙：每個分界都在線上

Wikipedia：「With a key properly cut and inserted into the groove on the end of the plug, the pins will rise causing them to align exactly at the shear point. This allows the plug to rotate, thus opening the lock.」（插進鎖芯端部溝槽的鑰匙只要齒開得正確，彈子就會升起，恰好在剪切點對齊。這樣鎖芯就能轉動，鎖也就開了。）Lockwiki：「Each pin stack must be properly aligned to allow pins to separate at the shear line. Once all pin stacks are properly aligned the plug can freely rotate and actuate the locking bolt to lock or unlock the lock.」（每組彈子都必須正確對齊，彈子才能在剪切線處分開。所有彈子組都對齊後，鎖芯就能自由轉動，帶動鎖舌來上鎖或開鎖。）

鎖芯一轉，彈子就在線上分開。The Engineering Mindset：「The driver pins will have been pushed up and will now fully sit within the housing while the key pins sits fully within the plug. This means the plug is now able to rotate.」（上彈子被推上去，此時完全待在鎖殼裡，下彈子則完全待在鎖芯裡。這表示鎖芯現在可以轉動了。）

## 差一道齒：被擋住

Wikipedia：「If the wrong key is used, the pins remain misaligned, preventing the plug from turning」（如果用錯了鑰匙，彈子就對不齊，鎖芯轉不動）。齒太深，上彈子就留在線上；齒太淺，下彈子就被推過了線。能同時擋住這兩種情況的設計由來已久：Wikipedia 談歷史時把雙向彈子鎖描述為「one where lifting the pins too much or too little prevented opening」（彈子抬得太高或太低都打不開的鎖）。Lockwiki：「An incorrect key will not align all components correctly; rotation of the plug will be blocked at the shear-line.」（錯誤的鑰匙無法讓所有零件正確對齊；鎖芯的轉動會在剪切線處被擋住。）

## 理論上最多 10 萬種鑰匙

Lockwiki：「Theoretically, most locks have a very high number of differs but in reality tolerances and bitting restrictions lower this number dramatically. For example, a 5 pin lock with 10 depth spacings has 10⁵ (100,000) theoretical key differs.」（理論上，大多數鎖的鑰匙差異數都非常高，但實際上公差和齒形限制會讓這個數字大幅下降。例如，一把五顆彈子、十級深度的鎖，理論上有 10⁵（100,000）種不同的鑰匙。）也就是 10 × 10 × 10 × 10 × 10。正如 Lockwiki 所說，實際會少一些；具體少多少，我們不給數字。

## 總鑰匙：第二個分界

Wikipedia：「In a master-keyed lock, some or all of the pin chambers in the lock have three pins in them instead of two. Between the driver pin and the key pin is a third pin called the spacer pin, also known as a master wafer. Thus each pin line has two shear points.」（在有總鑰匙的鎖裡，部分或全部彈子孔裡裝的是三顆彈子，而不是兩顆。上彈子和下彈子之間多了第三顆，叫中間彈子，也叫主片。這樣每列彈子就有兩個剪切點。）還有：「So the lock will open with two keys; one aligns the first set of shear points and the other aligns the second set of shear points.」（所以這把鎖能用兩把鑰匙打開：一把對齊第一組剪切點，另一把對齊第二組剪切點。）

一棟大樓就是這樣運作的：「Each tenant is given a key that only unlocks their own door, called the change key, but the second key is the master key, which unlocks all the doors.」（每位住戶拿到一把只能開自家門的鑰匙，叫分鑰匙；而第二把鑰匙是總鑰匙，能開所有的門。）

## 結論

1. 只有每組彈子都恰好在剪切線上分開，鎖芯才會轉動；沒有鑰匙時，彈簧會把上彈子推過這條線。
2. 你的鑰匙是一排高度：每道齒把各組彈子抬起不同的量，只要一道齒差一級，就有一顆彈子擋在路上。
3. 五顆彈子、十種深度，理論上最多 10 萬種鑰匙；總鑰匙能開，是因為中間彈子讓每組彈子多了第二個分界。

## 來源

- Wikipedia：[Pin tumbler lock](https://en.wikipedia.org/wiki/Pin_tumbler_lock)、[Master key](https://en.wikipedia.org/wiki/Master_keying)、[Bitting (key)](https://en.wikipedia.org/wiki/Bitting_(key))
- The Engineering Mindset，P. Evans，[How Padlocks Work](https://theengineeringmindset.com/how-padlocks-work/)（2020）
- Lockwiki：[Pin-tumbler](https://lockwiki.com/index.php/Pin-tumbler)、[Differs](https://lockwiki.com/index.php/Differs)

影片以程式碼製作動畫，腳本在 AI 協助下撰寫；上面每段引文都對照出處查證過。示意的部分：鎖和鑰匙的圖（比例、五組彈子、彈子長度、鑰匙孔、端面視圖）、齒形 2-6-4-8-3 和它均勻的十級深度、錯誤的鑰匙、總鑰匙鎖裡那組彈子的長度，以及一大堆鑰匙。本片只講原理，不涉及任何不用鑰匙開鎖的方法。影片為英文旁白。影片用 [Shotloop](https://oliverz.dev/zh-hant/products/shotloop) 製作：我做的免費 Mac 應用程式，用程式碼做科普短片，一個鏡頭一個鏡頭地修改。
