kapy academy

Puzzle boxes and cryptex

23 min readUpdated Nov 2026

Five rings of 26 letters give 26⁵ = 11,881,376 combinations. If each ring gives its position away by feel, it opens in 130 turns at most (5 × 26). What separates those two figures is a few tenths of a millimeter. In an ordinary mechanism, the clearance only has to let the part move. In a puzzle box it also has to block the wrong move and not show from outside where the lock is. Every clearance lives in a window with two walls: too tight, it jams the right move; too loose, it lets the wrong one through.

Locks you cannot see

A puzzle box is a lock with no keyhole. The key is a gesture: an order of moves, a path, a way of holding the box or a magnet in exactly the right spot. Four families print well, and each depends on one dimension.

0.20 per side1.5–2 rails0.5 × 45° chamfer12Elephant's foot: a flat face that binds1.83.6 at tip heightWall ≥ 2.0 at the mouth45° flankGrooveØ3 pinTilt αFriction angle φα > φ0°45°90°Stays put up to 45°Opens past 70–80°Magnet2 mm wallSteel ballSeat in the lidBall weightMagnet pull
The four hidden locks: narrow rails under the panel, the groove flank at 45°, the pin's friction angle and the magnet's pull through the wall.

Sliding panels in sequence

This is the classic Japanese box: Hakone puzzle boxes (himitsu-bako) were sold in Japan as souvenirs in the late nineteenth and early twentieth centuries, and there are four-move boxes and boxes with more than sixty. Each panel slides a few millimeters along its guide and, until it moves, its end blocks the next one. The panel takes a sliding fit: 0.20 mm per side on a modern bedslinger and 0.15 on an enclosed CoreXY (Real printed clearances). At 0.10–0.15 on a bedslinger, the panel drags instead of sliding.

A panel with the right clearance still jams if it bears face to face. A large printed face never comes out flat: the bed face carries elephant's foot, the part warps slightly and the top surface ripples. The parts touch only at the high points, and that is where they brake. Run the panel on rails 1.5–2 mm wide instead of on the whole face, and give the bed edge of both parts a 0.5 × 45° chamfer (The face on the bed).

The panel must not move on its own when you shake the box either. Give it a tab detent with a bump of at least 0.5 mm. A 0.2 bump sits inside the printer's scatter: sometimes you feel it, sometimes you do not. The tab and its slot are sized in Enclosure lids and Ball and spring detents.

Clearance also gives the game away. A slot with 0.4 per side casts a shadow that 0.2 does not. Hide the joint: let the panel show its edge against a wall rather than leave its outline in view.

Maze

In a maze box, a pin on the sleeve runs along a groove cut into the inner cylinder, and only the right path reaches the exit. It is a very long bayonet mount (Bayonet mount).

The groove has one flank that takes load and one that only guides. When you pull the sleeve off, the pin bears on the flank of the circumferential runs that lies on the mouth side (its face looks toward the base). That flank has to be square: one at 45° would push the pin outwards as hard as you pull. Print the cylinder upside down, as a tube, with the base separate, glued or held by two screws. The loaded flank then comes out as an upward-facing surface, square and clean, and the other one, which is the groove's roof during the print, gets the 45° chamfer so it does not overhang (Layer orientation for mechanisms). The sleeve prints the same way, as a tube with its base separate and its open rim on the bed: the pin, which sticks out horizontally from its wall, then has its square loaded face on top and a 45° V underneath. With the base on the bed, the loaded face would end up underneath, overhanging.

Maze box, in this example (mm)
Feature Value Why
Inner cylinder Ø50 Printed upside down, base separate
Sleeve Ø50.6 bore Free-running clearance, 0.30 per side: many runs and corners, and a large cylinder comes out slightly oval
Pin Ø3; stands 1.8 proud of the sleeve and reaches 1.5 into the groove
Groove 1.8 deep; 3.6 wide at 1.5 deep, 3.3 at the bottom and 5.1 at the mouth 0.30 per side at tip height; 0.3 free under the tip
Flanks Loaded flank square; the other at 45° The 45° one is on top during the print
Wall between runs ≥ 2.0 at the mouth Five line widths where it is thinnest: the pin cannot force its way through
Pins Two, at 180° The load is shared and the sleeve does not tilt

Use two pins at 180° and a maze with 180° symmetry. With only one, a hard pull tilts the sleeve, opens it on the opposite side and the pin leaves the groove.

Gravity bolt

A loose pin in a bore drops into its seat only when you hold the box the right way. The threshold does not depend on mass: the pin slides once the bore's tilt exceeds the friction angle, φ = atan μ. With typical values from Friction and wear, steel on printed plastic (μ = 0.2–0.35) gives 11–19°, and printed plastic on itself (μ = 0.3–0.5) gives 17–27°. Start there and measure.

A horizontal bore, with φ around 20°, trips as soon as someone picks the box up. In this example the bore is tilted 60° with the box upright, and the pin rests at the end that blocks the lid. To get it out, the bore has to tilt the other way by more than φ: you have to turn the box past 60° + φ, between 71° and 79° with a steel pin. On its side, at 90°, the box always opens. If you tip it 45° while handling it, the bore still falls 15° toward the lock and the pin stays put.

Where mass does count is against whatever holds the pin back: a plastic string, a burr, a drop of moisture. A steel pin weighs 6.3 times as much as the same pin in PLA (7.85 against 1.24 g/cm³). Use an off-the-shelf steel pin and a bore with free-running clearance, 0.25–0.30 per side. Tilted 60° in a box printed upright, the bore sits 30° from vertical and comes out round; if your design puts it horizontal, below Ø6 it prints clean without a teardrop (Designing out supports). A sharp knock along the bore does the same as tilting the box: it can be another lock or a flaw, depending on how you design it.

Magnetic bolt

A steel ball or pin inside the wall blocks the lid, and a magnet held outside, at exactly the right spot, drags it. The force needed is tiny: a Ø6 steel ball weighs 0.89 g, about 8.7 mN. A Ø6 × 2 mm N45 magnet holds about 7.3 N in contact with a steel plate. Through 2 mm of wall plus the channel clearance, about 2.3 mm in all, it keeps roughly 20 % of that or less on its axis, and it pulls less on a small ball than on a plate: between a few tenths of a newton and 1.5 N. Even in the worst case, the margin over the ball's weight is more than tenfold.

With that margin, the bolt fits behind 2 mm of wall and cannot be seen. Whether it can be heard is another matter: a loose ball in a channel with clearance rattles when you shake the box, like the gravity bolt's pin. Tighten the channel, add a dab of grease or add another noise to mislead. And without the magnet, something has to keep the ball in its seat: if only gravity holds it, the bolt is a gravity bolt as well and the box opens by itself upside down. Give it a light detent, or use a pin with a spring pushing it toward the lock.

The hard part is making sure someone who does not know the secret cannot find the spot. No marks, and a symmetric shape to mislead. Why the force drops so fast with distance is in Magnets in mechanisms; how to trap the ball during the print, in Embedding magnets and nuts mid-print.

The four locks combine in one box, with as many moves as you care to chain, but each added move is another contact with its own clearance window, and the errors add up (Assemblies and tolerance stackups).

How a combination cylinder works

Dan Brown coined the word cryptex for the novel The Da Vinci Code (2003), which credits it to Leonardo with no evidence that he designed one. Cryptex is now a registered trademark in the US, so from here on it is called a combination cylinder; the title uses the word you will search for. Its mechanism is that of any wheel combination lock, like the one on a suitcase or a bike lock: a set of discs, each with a notch, and a toothed bolt that only comes out when all the notches line up.

The cylinder has four parts, two of them repeated. The stator is a fixed tube, joined to the bottom cap, with an axial slot through which the lugs show. The vault is the inner tube you pull out, which holds the message; it carries one lug per ring, all in a row. The rings turn on the stator, and each has a gate in its bore: the through notch that lets the lug pass. Between one ring and the next sits a spacer washer (spacer, from here on), keyed to the stator so it does not turn, with a slot the lug runs along.

The key cannot be a rib standing proud of the stator, because the rings would not go on; nor can it sit in the lug slot, because it would close the lugs' path. It goes in a second axial slot in the stator, at 180° from the first, which takes an inner tab on each spacer. The rings pass over both slots.

Pull4.01014.0RingSpacerGateLugStatorVault1.0Engages 1.4Detent armDetent notchWindow ±1.2°One letter: 13.85°2.82.4Ø30.0 / Ø29.6Ø36.4 / Ø36.0Ø50KeySection A–A
The worked example in section. With the vault closed, each lug sits halfway along its spacer; when you pull, lug 3 hits the face of its ring, which is turned, and holds back the whole vault. On the right, the angular window of a gate against the pitch of one letter.

With the cylinder closed, each lug sits inside a spacer, beside its ring, and the rings turn without touching it. When you pull, each lug hits the face of its ring unless the gate is in front of it. The first ring's lug has to cross its own ring and every ring after it, so the vault only comes out when all five gates form one straight slot with the stator's. That is why all the gates are in the same row.

The combination is the angle of each gate relative to its letters. If you split the ring into two parts, a letter band and a gate ring, joined by a 26-tooth spline, you only have to take it apart to change the combination. Resettable combination locks on suitcases work this way.

Without spacers, turning one ring drags its neighbor through face friction and the combination scrambles itself. The spacer also carries the ring's detent and the reading line.

Worked example: five rings of 26 letters

The brief: five letter rings; room for a rolled-up €10 note (127 × 67 mm, so a tube 67 tall); PETG and a modern bedslinger, with a sliding fit of 0.20 per side. Every dimension that follows is a choice made for this example.

Combination cylinder, in this example (mm)
Part Dimension Value Where it comes from
Stator Outside / inside Ø36.0 / Ø30.0
Stator Lug slot 2.4 Lug 2.0 + 0.20 per side
Stator Key slot, at 180° 2.0 wide, 1.0 deep Spacer tab with 0.10 per side
Vault Outside / inside Ø29.6 / Ø25.6 30.0 − 2 × 0.20
Vault Usable space Ø25 × 70 The rolled-up note fits
Lug Width × axial length 2.0 × 2.0 From radius 14.8 to 19.6
Ring Bore / outside / width Ø36.4 / Ø50 / 10 Sliding on the stator
Ring Lug engagement 1.4 19.6 − 18.2
Gate Width / radial depth 2.8 / out to radius 20.2 Lug + 0.40 per side; 0.6 beyond the tip
Spacer Thickness 4.0 Lug 2.0 + 1.0 free each side
Stack Pitch / length 14.0 / 74 Six spacers and five rings

The angular window

The lug passes as long as the gate is off center by no more than (gate − lug)/2 = 0.4 mm of arc. At a radius of 19 mm, that is ±1.2°. One letter takes 360/26 = 13.85°, 4.59 mm of arc at that radius, against 0.4 mm of play: the neighboring letter is nowhere near opening. Narrowing the gate adds no security; what makes reading hard is the false gates (below).

The gate gets 0.40 per side, more than the sliding fit, because a printed slot comes out narrower than the model (Why holes print small). A 2.8 mm gate is seven line widths with a 0.4 nozzle, so the nozzle is not the limit. The limits are the window and the wall left between the true gate and the neighboring false one.

The window's other wall: if the ring stops outside ±1.2°, the right letter does not open. Three errors add up there. The printed detent notch lands within ±0.1 mm of its place, ±0.26° at radius 22. The spacer tab moves in its slot: with 0.10 per side at radius 17 that is ±0.34°, and the detent arm and the reading line move with it. And the ring, with 0.20 clearance on the stator, can sit off center and shift the gate by up to 0.2 mm, another ±0.6°. The worst case adds up to ±1.2°, exactly the window; the root sum square gives about ±0.7°. That is why the key takes a locating fit and not a sliding one: at 0.20 per side it would contribute ±0.67° and the worst case would fall outside.

Each ring's detent

On the side facing the pull handle, each ring carries 26 V notches at 45°, on a 22 mm radius circle (5.32 mm pitch) and 0.6 mm deep. At 45° the click is firm; at 30° it is light, and at 60° or more the detent locks. A curved arm cut into the spacer rides on them: 1.2 thick (six 0.20 layers), 5 wide and 12 long, in PETG. The arm lies flat and bends in Z, with its length in the plane of the layers, which is a valid orientation (Layer orientation for mechanisms).

With an arm like this, PETG works at 1.0 % strain, within what it tolerates under repeated bending. It pushes 1.6 N with the bump fully home and 0.4 N at rest. Jumping a notch takes 3.0–4.8 N, a torque of 0.066–0.106 N·m at radius 22: about 3–4 N with your finger on the rim of the ring. The full sizing is in Ball and spring detents.

The V draws the ring toward the bottom of the notch, but it does not always get there. With the arm at rest, the restoring torque is on the order of 3–5 mN·m, and the same arm presses the ring against the next spacer with a drag of 3–4 mN·m. With high friction, the ring can stop halfway up a flank. If the test piece shows it, give the arm more preload at rest.

False gates

When you pull the vault, differences of a few hundredths mean one lug always bears before the others. That ring is hard to turn; the rest turn freely. You turn it until it gives, which is its gate; the lug drops in and the next ring goes stiff. The combination comes out ring by ring: 130 turns against 11.9 million combinations. Tightening the clearances does not prevent it.

False gates make it harder. On the ring face the lug pulls against, cut 25 blind pockets 2.8 wide and 0.8 deep (four layers) at the 25 remaining positions. When you pull, the lug sinks 0.8 at any letter and the ring gives the same way at all of them. The price: to keep turning, you first have to push the vault back in.

They do not make it impossible. With the vault pulled, the lugs sitting in false gates bottom out and take load; the one in the true gate touches nothing, because the gate goes right through, and its ring rocks through its ±1.2° more freely than the others. And between pockets, the problem from the start of this section comes back: with ±0.1 scatter in depth, one bears before the rest. False gates turn the reading into slow, uncertain work; they do not stop it.

They have to match the true gate in width and in the edge of the bearing face, and match each other in depth. Check the wall between the true gate and the neighboring false one as well. It is thinnest at the edge of the bore, at radius 18.2: there the pitch is 4.40 mm and the wall 4.40 − 2.8 = 1.6 mm, four line widths. That is the minimum. On a smaller ring, or with wider gates, the wall disappears and the 25 false gates no longer fit.

Reading lineWithout false gatesOrder in which they give3Free1Stiff5Free2Free4FreePullWith false gatesLockedLockedLockedLockedLockedPullGate2.8Wall ≥ 1.6False gate0.8 deep2.0
The five rings unrolled at radius 19. Top, without false gates: lug 2 bears first, its ring goes stiff and the combination comes out in order. Bottom, with false gates: each lug sinks 0.8 at any letter and every ring locks the same way.

Stack tolerances

Each lug sits halfway along a 4.0 spacer, with 1.0 free on each side, and the stack advances 14.0 per ring. Up to the last lug there are nine dimensions in series: the bottom cap, four rings and four spacers. At ±0.1 each, the worst case adds up to ±0.9; the root sum square gives ±0.3 (Assemblies and tolerance stackups). Also leave 0.4 of total axial play at the cap so the rings turn without being pinched; that play adds to the chain too. And the vault contributes its share: each lug's position and its seating against the bottom.

The 1.0 margin covers the root sum square plus the play (0.3 + 0.4 = 0.7); the worst case, it does not. If a lug ends up rubbing a spacer face, it brakes the ring and gives a false reading by feel. So print the vault last: assemble the stack, measure the distance from each spacer to the bottom cap and place the lugs from those measurements. The whole chain then comes down to the vault's accuracy.

The mouth cap is held by two M3 screws in heat-set inserts (Designing for heat-set inserts), with its own slot lined up with the stator's. That way you can take it off to change the combination or replace a broken ring. Do not try to print the cylinder in place: the rings and the keyed spacers are fitted onto the stator, and the vault goes in afterwards.

  • Everything upright, axis vertical. The holes come out round, and gates, slots and lugs end up as vertical walls.
  • Rings with the false-gate face up. On the bed face, the flat bottom of a 2.8 pocket becomes an unsupported ceiling, and its depth would no longer be the same in all 25: exactly the difference that betrays the true one. The 45° V notches, which support themselves, go on the bed face; watch the elephant's foot there, since it would fill a 0.6 V (The face on the bed).
  • Vault lugs: they stick out horizontally. Give them a 45° underside and print the vault with the handle end up: the pulling face comes out square, and the 45° face acts as a lead-in ramp that centers the ring when you push. Print the handle separately and glue or screw it on, so the vault is an open tube with no roof.
  • Pockets and notches: whole layers (0.8 and 0.6 are four and three 0.20 layers).
  • Letters: raised 0.6 on the outside wall, about 6 mm tall; at Ø50 each letter has 6.0 mm of arc (Minimum features and text). Two colors on a vertical wall need a filament switcher (Designing for multicolor).
  • 0.5 × 45° chamfer on the bed edge of rings and spacers, because they rub face to face.

When it fails

Symptom → cause → fix
Symptom Cause Fix
The vault comes out on a wrong letter The wall between gate and false gate breaks and joins them, or the ring rocks and the lug bears on the edge and jumps Wall ≥ 1.6 (four line widths); lug engagement ≥ 1.4; spacers that hold the ring square
The right word does not open it, or it comes out in jerks Ring stopped outside ±1.2° (soft detent, unevenly spaced notches, key with play), gate narrower than the model, or a lug rubbing a spacer 45° detent; locating fit on the key; gate test piece; measure the stack and print the vault afterwards
Turning one ring moves its neighbor Spacer not keyed, or no spacer Spacers keyed to the stator
The combination can be felt by pulling the vault No false gates, or false gates differing from the true one in width, depth or edge 25 identical false gates, printed with the pocket face up
One ring moves more loosely than the others with the vault pulled Its lug sits in the true gate and does not bottom out That is the limit of false gates; reduce the detent's angular play
Letters stop between two positions Detent notch 0.2–0.3 deep, inside the printer's scatter, or high friction 0.6 depth (never under 0.5), 45° V, more preload on the arm
A sliding panel jams even with the right clearance Face-to-face bearing with elephant's foot or warping 1.5–2 mm rails; chamfer on the bed face
The panel moves by itself when you shake the box No detent Tab with a bump ≥ 0.5
The maze pin catches in the circumferential runs Flat, overhanging groove roof with burrs 45° flank on top in the print, pin with a V underside, 0.30 clearance
The sleeve comes out of the maze under a hard pull Loaded flank at 45°, or a single pin and the sleeve tilts Square loaded flank, two pins at 180°, wall ≥ 2.0
The gravity bolt does not drop Tight bore, plastic strings, light plastic pin 0.25–0.30 clearance, steel pin, run a drill through the bore
The gravity bolt opens when you pick the box up Opening position too close to the handling position Tilted bore: opening should take more than 70°
The magnetic bolt opens upside down Only gravity holds the ball Light detent or spring-loaded pin

How to test it

Before the full assembly, print a single-ring test piece: a length of stator and vault with one lug, one ring and two spacers. On the right letter, the lug should pass without forcing; on the two neighboring letters, it should not. Measure the detent's click force with a spring balance or a kitchen scale (Testing a mechanism before you trust it). The clearance coupons to print first are in Test coupons.

With the assembly built, run the feel test. Hang a kilogram from the vault, about 10 N, and turn each ring a full revolution. If any of them gives at a different spot from the rest, the combination can be read. Then, with the vault pulled, wiggle each ring within its play: if one moves more loosely than the others, it betrays its gate. Have someone who does not know the word run both tests.

Shake each closed box in every position and listen for rattles. For the gravity bolt, use a protractor or your phone's inclinometer: note the angle at which the pin drops and compare it with the calculation. Put the maze through 50 open-and-close cycles and look for where the pin catches.

A printed puzzle box or cylinder opens with a screwdriver in a minute: it is a game, not a safe. Do not keep anything inside that you are not prepared to lose.

See also

Design it in KapyCAD

Sketch the mechanism with these dimensions. Each one stays a value you can change after the first test print.

Free plan, no card. Runs in your browser, nothing to install.

Open the editor

Still have a question?