In 1940, a team of American cryptanalysts led by William Friedman broke the Japanese diplomatic cipher known to Americans as "Purple." The machine that generated Purple was rebuilt by the Americans without ever having seen the original—based entirely on analysis of intercepted ciphertext. This feat of cryptanalysis was arguably comparable to breaking Enigma.
By December 1941, the Americans could read Japanese diplomatic traffic almost in real time. The intelligence product, codenamed "Magic," revealed that Japan was preparing for war and had set a deadline for diplomatic negotiations. The famous 14-part message breaking off negotiations was decoded before the Japanese ambassador could deliver it.
Yet the intelligence failed to prevent Pearl Harbor for multiple reasons: there was no specific mention of Pearl Harbor as a target, the vast volume of decrypted traffic made it difficult to identify critical messages, bureaucratic rivalries between Army and Navy intelligence created information silos, and the decoded final message reached decision-makers too late on the morning of December 7. The failure became the textbook example of how intelligence without proper analysis and dissemination is worthless.