Cipher Machines





CHM logo

Pin and Lug Cipher

(Download this presentation Hagelin Cipher Machines: The World’s Most Successful and Controversial or view it online)

Hagelin C-35, the first pin and lug cipher

The pin and lug cipher was invented by Boris Hagelin in 1935. He got the idea from a coin changing machine, which he designed for a client who never paid for the plans. Instead, he had the inspiration to incorporate the mechanical adding function into a cipher capability. This cipher is entirely mechanical and has a printing function, making it easy to use. It was adopted by the US Army as the M-209 and 140,000 were used in WW2.

The Hagelin story begins with one of the original 4 inventors of the electro-mechanical rotors, Arvid Gerhard Damm of Sweden. He was the last of the four cipher machine inventors at the end of WW1 to file for a patent on his rotor based cipher machine. His was the only rotor machine to have irregular stepping, which avoided the weakness of the odometer-style rotor stepping in the other electro-mechanical rotors. Two investors were K.W. Hagelin and Emanuel Nobel (nephew of Alfred, famous for his dynamite and prize). Hagelin had his son, Boris, join the firm in 1922 in order to protect his investment.

Boris Hagelin

Boris Hagelin (1892-1983) was a Swedish engineer, born in Russia, who took over management of Damm's company in 1925. The Swedish army made the first large purchase in 1926 and Damm died early the following year. Hagelin bought the firm and went on to have the most successful and controversial cipher machine company in history.

The first cipher machine produced was the B-21, which had two rotors and two pairs of pinwheels to produce an irregular stepping action for the two rotors. This mechanism will continue to play a key role in all the future mechanical cipher machines from Hagelin's firms and also for the later derivative cipher machine from the Swedish company Transvertex. The pinwheel was a rotating wheel with pins inserted radially near the circumference. These pins could be pushed to the right or left, making it active or inactive. Each pinwheel would advance one position with each keystroke and they had a mutually prime number of pins, allowing for a long key period. The B-21 also had a light panel and keyboard, like the Enigma machine. In 1932 the French Army wanted a handheld version of the B-21 with printing capability, so Hagelin produced the B-211, which was successful and helped to fund further development.

US Army M-209

In 1934 Hagelin got the idea to adapt the calculating function from a money changer into a new cipher machine. He also employed the pinwheel from the B-21 combined with a lug cage to make his first pin and lug cipher device, called the C-35. The “35” in the model number designates the year it was first produced, which was continued in future products. This design is a completely different cryptologic technology from the earlier B model cipher machines or any of the other electro-mechanical rotor based devices. Instead of an electrical signal mixing the alphabet inside each rotor, the rotors mechanically select a reciprocal alphabet by adding some number of characters to the plaintext based on the number of lugs engaged by the pins. In fact, the 5 rotors in the C-35 did not contain all the letters of the alphabet but used a mutually prime number of pins: 17, 19, 21, 23 and 25. This allows for 3,900,225 characters of a message before the sequence would repeat.

Hagelin continued to make improvements to his pin and lug design, making the C-36, C-37 and C-38 adding a sixth wheel and moveable lugs. In 1940, Hagelin took his C-38 to the US and sold his design to the US government. This machine was manufactured by the L.C. Smith-Corona Typewriter Company under license from Hagelin's firm. 140,000 M-209s were made during WW2 at a cost of $64 each, making Hagelin the first millionaire from selling cipher technology.

Also in 1944, Hagelin produced the C-446 which was compatible with the US M-209 and was sold to other Allied countries. It had 2 paper tape printers, one for the plaintext and the other for the ciphertext.

Zug, Switzerland – home of Crypto AG

After the war, Sweden passed laws classifying cipher machines as munitions which could not be exported. Hagelin moved his company to Zug, Switzerland in 1952, renaming it Crypto AG. His technical director, Vigo Lindstein, along with 3 others set up a new company, AB Transvertex, to manufacture cipher machines for the Swedish military. Their first cipher machine, the HC-9, also had a pin and lug function, but instead of the Hagelin mechanism, it was replaced with a punch card for ease of operations. It is curious that later Hagelin machines would be denoted with the "HC" model and a number, but the HC-9 from Transvertex was the first "HC" model produced, likely a tribute to Hagelin. The HC probably stands for "Hagelin Cipher" and the 9 represents Hagelin’s 9th cipher device.

In 1952 Hagelin's new company, Crypto AG, introduced the wildly popular C-52 and the CX-52, with a stronger encipherment than the previous models. The handheld CD-55 was added in 1955 for clandestine operations and was compatible with the CX-52. These machines would go on to be the most successful cipher machines ever produced, selling to 120 countries around the world. These were used for the most sensitive military, diplomatic and financial messages with complete confidence of the users based on the trust of a Swiss bank and the precision engineering of a Swiss watch.

William F. Friedman (1891-1969)

What the users of these Hagelin machines did not know was the single greatest coup in the history of military intelligence. In 1957, William Friedman was called out of retirement by the US NSA to make a secret deal with Boris Hagelin, giving the US access into all the secret communications using the Hagelin machines. The US shared this information with England. Later, as the cipher technology advanced from mechanical devices to electronics, the new Hagelin machines installed a back door written by the NSA. Dictators and madmen, such as the Iranian Islamic regime, Saddam Hussein, Moammar Gadhafi, Ferdinand Marcos, Idi Amin, as well as friendly nations and the Vatican all had their most secret communications read instantly by Washington and London. This unfettered access would continue for decades.

This open book into the world's secrets would start to unravel in 1983. A US Naval Intelligence officer, Jonathan Pollard, acting as an Israeli spy sold this highly classified information (well above top secret) to Israel. This sensitive information was then traded to the Soviet Union in return for them allowing more Soviet Jews to immigrate to Israel. The rest of the world remained oblivious to the espionage battles over the Hagelin cipher machines and continued to use them. It turns out the Russians probably already knew this secret from two other US spies, Aldrich Ames and Robert Hanssen.

Hans Buehler
Crypto AG salesman

The lid was blown off this greatest of secrets in a very public way in March 1992. Hans Buehler, the top salesman for Crypto AG was arrested in Iran and charged with spying for the US and Germany, for selling cipher machines with the hidden back door. Buehler was not aware of the secret deal between Hagelin and the NSA, so he maintained his innocence and Crypto AG's integrity for 9 months. He was finally released after Crypto AG and, curiously, Siemens agreed to pay a million dollar ransom. Siemens’ role in the ransom furthered speculation that Crypto AG was secretly partnered with that German company, with close ties to German intelligence.

Within weeks of his return to Switzerland, Buehler was fired by Crypto AG and was billed for his million dollar ransom. He went on to discover the truth of the secret NSA deal from previously tight-lipped employees and wrote a book about his ordeal and discoveries. Crypto AG went on to sue Buehler but settled out of court before the Crypto AG engineers could testify about their knowledge of the NSA deal. Buehler was released by Iran in January 1993 and despite claims of innocence from Crypto AG, sales plummeted. The three and a half decades of NSA access to the world's secrets came to a grinding halt as more countries understood the scope of the deception.

More Information on a Unique Pin and Lug Machines

Swiss Transvertex HC-9 Cipher Machine

Hagelin M-209 Cipher Machine

Pin and Lug Devices

from the Cipher History Museum

Hagelin C-38SX - 1938


The C-38 pin and lug cipher machine was invented by Boris Hagelin in 1938 and was an upgrade from his first pin and lug machine invented in 1935. It is an entirely mechanical device that uses an adding machine function to encrypt a message and also has a printing function.

During WW2, Boris Hagelin sold the C-38 to the US. The US made the C-38 more rugged and simplified the design, renaming it the M-209. One simplification was to fix the reciprocal alphabet, which can be rotated through the 26 letters on the C-38. Also, the C-38 has 2 locks, one for the outside lid and another “officer lock” for the inner lid. The M-209 has no locks.

US Army M-209 Models A and B - 1942-45


The M-209 is a “pin and lug” cipher machine first invented by Boris Hagelin in 1935. It is an entirely mechanical device that uses an adding machine function to encrypt a message. It is small, easy to use and gives printed output. 140,000 were made from 1942-45 and were used until the early 1960s.

The pin is located behind each letter in the 6 wheels and can be shifted left or right. If shifted to the right, it is active and can engage a moveable lug in the large cage behind the wheels. Manually setting the pins and lugs was the key, which was changed daily.

The Germans were able to break the M-209 code in about 4 hours, but this was sufficient for use as a battlefield cipher.

Swedish Transvertex HC-9 - 1950s


The HC-9 was invented by Transvertex in the early 1950s and is one of only two pin and lug cipher machines not made by Hagelin. The other pin and lug device was the German SG-41, which Hagelin derisively called the C-41. Hagelin relocated his company in 1952 from Sweden to Switzerland and his Technical Director became the CEO of Transvertex. The name HC-9 is probably a tribute to Hagelin, with HC short for Hagelin Cipher and the 9 represents the 9th Hagelin cipher machine.

The HC-9 is entirely mechanical with 5 wheels, each with a mutually prime number of characters. It uses a punched card instead of manual settings of pins and lugs, making it easier to use and less error-prone. A second card is inserted in the front of the machine which has 16 reciprocal alphabets – all the other Hagelin machines have only one.

Hagelin CX-52 - 1952


The CX-52 was invented in 1952 and was the last and most complicated of the Hagelin pin and lug ciphers. It has 6 interchangeable wheels from a set of 12 and a changeable reciprocal alphabet. The wheels have a mutually prime number of pins from 25 to 47 and move in an irregular fashion. The CX-52 was sold to over 120 countries for 25 years before being replaced in the early 1970s with electronic cipher machines.

In 1992, the biggest sting in cryptologic history was revealed. A secret deal between Boris Hagelin and the US NSA allowed access to the Hagelin ciphers for over 35 years.

Hagelin CD-57 Handheld Cipher - 1957


The Hagelin CD-57 is a handheld pin and lug cipher invented in 1957 to satisfy a French Army requirement for a pocket-size cipher compatible with the CX-52. This also became popular with other military and clandestine organizations due to its small size.

The CD-57 comes with 12 wheels, of which 6 are used in the machine. Instead of mixing the 12 wheels at random, it was often used with 2 sets of 6 wheels. This allowed for the wheels and pins to be set ahead of time and simply inserted into the machine.

Copyright © 2016 by Ralph Simpson - Creative Commons Attribution - ShareAlike 4.0 International License