WWII was a war of deception and subterfuge. There is no better example of such deception than Pearl Harbor. On the morning of December 7th, 1941, the Japanese attacked Pearl Harbor while still holding peace talks with the United States. The Japanese did send a declaration of war, which conveniently did not reach the Americans until after Pearl Harbor was in flames. There is some speculation that the US had decoded a message alerting them of an imminent attack on Pearl Harbor and the island of Oahu. Regardless of whether the cryptographers had uncovered the plans to attack Pearl Harbor in a timely manner, they became vital to the subsequent war effort.
During WWI an American Naval officer was able to steal an operating code book from the Japanese, enabling American cryptographers to decipher Japanese messages. The Japanese may have suspected as much and attempted to create a more complex code. Unfortunately for the Japanese, the US quickly broke that one as well. Once Germany declared war in 1939, the Japanese system became much more sophisticated. That advancement was due to technical support they received from Germany. Considered unbreakable, the cipher was named Enigma.
For years, American and British intelligence officers slaved over Enigma, hoping to glean vital information from the Axis powers. Initially, they were marginally successful at cracking the codes but not quickly enough for the information to be of any substantial use. Eventually, cryptographers William Friedman and Frank Rowlett, along with a team of translators and technicians, were able to speed up the process, providing invaluable information to the Allied powers. Near the end of the war, Churchill, Roosevelt, and Eisenhower were all reading messages containing German military information, sent by General Hiroshi to Tokyo. Pride became the downfall of the Japanese as they assumed that their Enigma-like cipher was absolutely unbreakable. They refused to believe that Allied Intelligence had broken the cipher, instead believing that someone had betrayed them.
The actual process of decrypting messages was complicated and exhausting, since incorrect information could be as disastrous as good information was vital. The United States had listening stations in Hawaii, Guam, Alaska and Bainbridge Island in Washington State. Those stations collected the raw information. The message was then deciphered before it was translated into English. While the whole process was a joint effort between the Army and Navy, most of the translations were accomplished by the Navy as they had more Japanese speaking officers. The final step was the toughest: judging whether the information was substantive. Lives were depending on this final step. Thankfully, the United States used much of the information gathered to great effect.