Japan’s Enigma Codes

Reading Time: 6 minutes

Today, the effect of codebreaking in the European theatre is widely acknowledged and understood. Since the mid-1970s, when wartime operations at Bletchley Park were declassified for the first time, historians have placed a great emphasis on the breaking of the Enigma code and its contribution to victory over Germany. However, the story of Japan’s secret codes and how they were deciphered has been broadly overlooked, despite their equally profound effect on the war.

There had been intermittent fighting between China and Japan since 1931, following the Japanese invasion and occupation of the Chinese province of Manchuria. However, a total war between the two did not break out until July 1937, when a border skirmish known as the Marco Polo Bridge Incident resulted in Japan occupying the major northern cities of Beijing and Tianjin. A Chinese counterattack on the Japanese concession in Shanghai was repelled, and Japan, expecting a quick victory, embarked on a major offensive from the North and along the Yangtze River to destroy the armies of Chinese Nationalist leader Chiang Kai-shek.

Instead, the Chinese forces retreated largely intact into the country’s interior, while Chiang Kai-shek relocated his government to the Sichuanese city of Chongqing. For the first time, the Chinese refused to negotiate or back down, forcing the Japanese into a war of attrition which they knew, with their weakened economy and smaller population, they were unlikely to win in the long-term.

As Japan looked for ways of escalating the conflict against China, it began to edge ever closer to war with the Western powers. Japanese atrocities attracted widespread condemnation in the United States, and it ignored repeated American calls to withdraw its forces from all occupied territories. Instead, in September 1940 it expanded the war by occupying the northern regions of French Indochina, which were being used as a transport link for war material entering China. This proved to be the final straw for President Roosevelt, who, in November 1940 authorised the first instalment of financial aid to China, as well as an embargo on iron, steel and copper to Japan. However, the Japanese took control of the rest of Indochina in July 1941, prompting the US to launch an oil embargo on 1 August. Japan, which acquired 94% of its oil from the US, was now placed in a difficult position; without an alternate source of oil, the war against China could not be pursued for more than a few years. But since retreat was unthinkable, plans were drawn up to push south in a massive operation to seize the nearest major sources of oil: British Burma (modern-day Myanmar) and the Dutch East Indies (modern-day Indonesia).

Since both the UK and the Netherlands were embroiled in the European conflict, the only country that could conceivably stop Japan was the United States, which operated a powerful Pacific fleet out of Pearl Harbour in Hawaii. To eliminate this threat, on 7 December 1941 Japanese aircraft carriers launched a surprise attack on Pearl Harbour – bringing the US into the Second World War – and in the following two months Japan enjoyed great success, capturing Hong Kong, Burma, the Philippines, Malaya and the Dutch East Indies in quick succession. By January 1941 the Allies were left in a desperate situation.

Both the US and UK had been active in breaking Japanese diplomatic codes before the war. In 1919 the British had established the Government Code and Cypher School (GC&CS), predecessor to the modern-day GCHQ, which moved to Bletchley Park in 1938. It operated a station in Hong Kong (later evacuated to Ceylon) called the Far East Combined Bureau to monitor Japanese radio transmissions. In the US, the army had its Signals Intelligence Service (SIS) whilst the navy’s codebreaking department was known as OP-20-G. The rivalry between SIS and OP-20-G was so fierce that to reduce unnecessary competition, the army decoded all traffic on even dates, the navy on odd dates.

In the late 1930s, the Germans had developed an advanced Enigma machine that was able to scramble every input seven times. This was far more secure than that of their Japanese counterparts, who used RED: their main diplomatic code of the interwar period. It used a Roman alphabet, and so the user had to write in romanised Japanese or rōmaji. However, to cut down on telegraph costs, which gave a discount for pronounceable words instead of random strings of letters, the machine deciphered the 20 consonants and 6 vowels separately (the letter Y was treated as a vowel). This meant that any consonant input would come out as a consonant, and any vowel input would come out as a vowel; a major flaw which created a distinct ‘sixes and twenties’ pattern.

The GC&CS broke this code as early as 1934, and the SIS by 1936. However, decrypted traffic from RED revealed in 1938 that a new machine, dubbed PURPLE, was under construction. The first diplomatic messages in PURPLE were transmitted in March 1939, and it proved to be a far tougher nut to crack. PURPLE continued to separate the letters into the six vowels and twenty consonants for encryption, but instead of rotors it used stepping switches, which were far more effective in scrambling text. A key upgrade on PURPLE was a plugboard at the front of the device which could swap any two letters; this meant that any consonant could be encrypted as a vowel and vice-versa, for example by swapping the letter ‘t’ with the letter ‘a’.

Two separate groups of stepping switches for the sixes and twenties.

The SIS, led by cryptographer William F. Friedman, took the lead in deciphering PURPLE. Early on it was realised that since each stepping switch had 25 output positions, and the sixes only used one stepping switch, the code for the sixes must only use 25 permutations of the alphabet, i.e. every 25 letters the machine would go back to using the same scrambled alphabet. Extending this to the twenties, which used three stepping switches, they used 253 permutations of the alphabet, meaning that every 15,625 letters, the list of alphabets would repeat. Thus, all that was necessary to crack the code would be to know the indicator setting of the device, which set which alphabet in the list of permutations it used first. By intercepting a number of messages with the same indicator setting, the team were able to create a replica machine which could crack the code by late 1940.

Since PURPLE was a diplomatic code, intercepted messages rarely gave insight into Japanese military operations. However, in an unlikely turn of events it proved to be an invaluable source of intelligence on Germany throughout the war. The Japanese ambassador to Germany, Hiroshi Oshima, sent regular updates to the foreign office in Tokyo about Germany’s war situation; this included advanced knowledge of Operation Barbarossa, as well as detailed information on the Atlantic Wall defences in the run-up to D-Day. Although warned by German intelligence of the weakness of PURPLE, the Japanese foreign office remained confident in its security throughout the war, unwittingly turning Oshima into the Allies’ “main basis of information regarding Hitler’s intentions in Europe”, according to US general George Marshall.

Whilst Japanese diplomats used RED and PURPLE, the Japanese Navy had its own code, JN-25, which was introduced in June 1939. JN-25 used a codebook containing nearly 30,000 common Japanese words and phrases, each of which were assigned a 5-digit code. For example, a full-stop was assigned the code 50418. The codebook had a supplementary 300-page additive book, which had 100 random 5-digit codes on each page. To encrypt a message, the 5-digit code for a full-stop (50418) would be added to a 5-digit additive code from the book (e.g. 65358) without carrying over place value, to create the code 15766. This would then be transmitted to the intended receiver, who would decrypt the message by subtracting the additive code. Obviously, for this to work each message had to include an indicator to inform the recipient where in the additive book the sender began encrypting.

A JN-25 additive book

The British cryptographer John Tiltman, helped by his GC&CS colleague Alan Turing, had established how JN-25 worked by the beginning of 1941. From there, the US Navy’s OP-20-G, led by cryptographer Joseph Rochefort, took the lead in attempting to decode it. Since OP-20-G had access to a pool of thousands of intercepted messages, it was possible for an IBM punched-card tabulating computer to compare values of codes and group together those that had the same additive. This was key in stripping away the additive codes to leave the original codebook values. From there, the codebook values would be matched up to their Japanese meaning by comparing them to stereotyped messages, e.g. weather reports or position data which followed a set format and included set phrases.

Using this process US cryptanalysts were able to make progress, but they were set back by a new version of the code, JN-25b, which was introduced on 1 December 1940, as well as new additive books introduced in August and December 1941. However, by early 1942, the Allies could decipher most messages and continued to do so, despite continued changes to the code and additive book for the rest of the war.

The intelligence gained from intercepting JN-25 would prove critical to the Allied victory. In May 1942, after capturing the Dutch East Indies, a Japanese convoy accompanied by two carriers was dispatched to capture the New Guinean capital of Port Moresby. If the Japanese succeeded, New Guinea could be used as a springboard for further incursions into the Solomon Islands, Fiji, and eventually Australia. The attack on Port Moresby was meant to be a surprise, but intercepted JN-25 messages gave the US time to send two of its own carriers, resulting in the Battle of the Coral Sea – which ultimately forced a Japanese retreat. Just a month later in June 1942, decrypted JN-25 messages helped to foil another Japanese surprise attack, informing the Americans ahead of time that a battle fleet was heading for Midway. The ensuing Battle of Midway would be the turning point in the Pacific, as the US sank four Japanese carriers for one of their own. Finally, in April 1943 deciphered JN-25 communications allowed US pilots to intercept and shoot down the plane carrying Marshal Admiral Isoroku Yamamoto, the architect of Pearl Harbour and commander-in-chief of the Japanese navy, over Bougainville Island.

However, there is one aspect regarding Japanese codes that has been so far neglected: the Pearl Harbour advance-knowledge conspiracy theory. It is asserted by some that British and/or American cryptanalysts were already able to decipher enough of PURPLE and JN-25 before December 1941 to predict the Pearl Harbour attack. Either the British did not inform the Americans, or the American leadership under Roosevelt willingly did nothing to prevent it, in order to provoke a US entry into the war.

The vast majority of the historical orthodoxy continue to assert that this theory is incorrect. As mentioned, PURPLE had indeed been broken by late 1940, but as a diplomatic code none of the intercepted messages in the runup to Pearl Harbour gave forewarning of the location of the attack – information restricted to military planners. The closest PURPLE came to revealing the attack was a message sent to the Japanese Embassy in Washington, decoded by SIS on the 6 and 7 December, which instructed the Japanese ambassador to break off relations but gave no mention of Pearl Harbour. In terms of JN-25, cryptanalysts were indeed making progress by 1940/1941, but as mentioned the change to JN-25b in December 1940 and the introduction of new additive books in August and December 1941 (the latter just three days before the attack) set cryptographers back such that they were not able to decrypt Japanese naval communications in the immediate leadup to Pearl Harbour. Thus, whilst Japan’s enigma codes played a crucial part in how the Allies waged the war in the Pacific, they did not play a role in how it began.

https://www.nsa.gov/History/Cryptologic-History/Historical-Events/Article-View/Article/2740680/jn-25/

https://www.mathscinotes.com/2014/01/excellent-video-on-breaking-the-japanese-jn-25-code-during-ww2/

Jarvis, S., 1997. Japanese Codes. Bletchley Park Trust. 

Kahn, D., 1996. The Codebreakers: The Comprehensive History of Secret Communication from Ancient Times to the Internet. Simon and Schuster. 

Kahn, D., 1980. Codebreaking in World Wars I and II: The Major Successes and Failures, Their Causes and Their Effects. The Historical Journal. 

Stripp, A., 2012. Codebreaker in the Far East. Routledge.  

Smith, M., 2001. The Emperor’s Codes: The Breaking of Japan’s Secret Ciphers. Arcade Publishing.