The Battle of Midway, which ran from the fourth through seventh of June 1942, was one of the American military’s biggest victories over the Japanese navy during World War II. Seventy-five years ago this past Sunday, the first bombs fell in what was supposed to have been a Japanese ambush. But by the end of the battle, over 3,000 Japanese sailors were killed and four aircraft carriers destroyed, while America lost only around 300 sailors and one carrier.

The key to this remarkable victory was breaking Japan’s naval codes. Although less famous than the effort to break Germany’s Enigma code, this cryptographic feat played its own central role in winning the war.

American cryptographers had been engaged in a “silent war” against Japanese cryptography for some 20 years, U.S. Captain Duane Whitlock said in a 1994 presentation. That war began in 1921, when the Office of Naval Intelligence got its hands on a copy of the Japanese Navy’s secret codebook, allowing them to translate the book-ciphered messages that they were able to intercept.

Intercepting messages wasn’t easy, though, and, to make things harder, the Japanese occasionally updated their codes. In 1939, Japan started using a system designated JN-25, which introduced both a new codebook and a second codebook for encrypting the encryptions. It updated one or the other multiple times in the years to come, with the most prominent version known as JN-25b. But the more any encryption tool was used, the easier it became to decode, and JN-25b was used very frequently as naval warfare between America and Japan ramped up.

The Japanese also inadvertently dropped some hints. Codebreakers began to notice long, frequently used phrases that they could use to work out the rest of a message. For example, the Japanese military was particularly formal when sending messages to their superiors, and known phrases — “I have the honor to inform your Excellency” — provided a key that helped the Allies figure out the rest of a codebook.

Even so, it took some 700 people in the U.S. Navy cryptanalysis centers to break open JN-25b. Of those, two-thirds were responsible for tracing and intercepting Japanese transmissions, and the rest worked with rudimentary IBM computers to decode them.

Pearl Harbor, home to the U.S. Pacific Fleet and a major cryptanalysis center, in October 1931.

Americans cryptographers made steady progress — including a breakthrough in 1941 when they compared notes with British codebreakers — although (by most reports) they weren’t able to predict the December 1941 attack on Pearl Harbor. By early 1942, they could reportedly understand 10 to 15 percent of any transmissions that they intercepted from the Japanese navy.

When they started getting reports of a massive attack planned against an unknown target known as AF, however, the Navy had to get creative. Suspecting that the target was the military base on Midway Island, Navy Commander Joe Rochefort had the base send out a fake emergency signal saying that their water purification system had broken down. Risking the chance of raising Japanese suspicions, they didn’t bother encoding the message to make sure that it was intercepted and read.

After cryptographers intercepted a Japanese message saying that AF didn’t have water and was vulnerable, they knew they had correctly guessed the site of the upcoming battle. Japan had taken the bait, and now the American navy could begin to prepare.

U.S. bombers attack Japanese ships in the Battle of Midway.

On the day of the attack, the Japanese navy had split their forces into three groups, hoping to lure American troops away from the base before hitting the unguarded facility with multiple-pronged assault. But because all of these plans were transmitted among Japanese forces via JN-25b, American forces knew exactly what to expect and set up an ambush of their own.

And the rest is history, with the U.S. victory serving as a turning point in the war against Japan. As Whitlock concluded, had it not been for the success of cryptographers in the silent war, “… the shooting war in the Pacific would have taken a far different and much more painful course.”

Photos via U.S. Navy, US Navy, Flickr / San Diego Air & Space Museum Archives