His career in cryptology began with his work in the code room, as he broke the U.S. government codes that crossed his desk. At that time, American codes were very weak and Yardley solved them easily. He was shocked to learn that President Wilson was using a code that had been in use for over ten years. The weakness of American codes worried Yardley, especially considering the war in Europe, so in May 1916 he began writing a hundred-page "Solution of American Diplomatic Codes", which he gave to his boss. Breaking American codes got Yardley wondering about the codes of other countries.
American participation in the war gave Yardley an opportunity to convince Major Ralph Van Deman of the need to set up a section to break other countries' codes. In June 1917, Yardley became a 2nd lieutenant in the Signal Corps and head of the newly created eighth section of military intelligence, MI-8. One early case was the cryptogram discovered in the clothing of German spy Lothar Witzke after he was arrested at the Mexican border in 1918. The evidence linked Witzke to significant sabotage activity in the U.S.
Yardley proved to be a very good administrator and during the war the people of MI-8 performed well even if they did not have any spectacular successes. After the war, the American Army and the State department decided to jointly fund MI-8 and Yardley continued as head of the "Cipher Bureau". They located their operations in New York City for legal reasons.
Cracking Japanese codes was a priority. David Kahn states:
The most important target was Japan. Its belligerence toward China jeopardized America's Open Door policy. Its emigrants exacerbated American racism. Its naval growth menaced American power in the western Pacific. Its commercial expansion threatened American dominance of Far Eastern markets.
After almost a year, Yardley and his staff finally managed to break the Japanese codes and were still reading Japanese diplomatic traffic when Washington hosted the Washington Naval Conference in 1921. The information the Cipher Bureau provided the American delegation regarding the Japanese government's absolute minimum acceptable battleship requirements was instrumental in getting the Japanese side to agree to a 5:3 ratio instead of the 10:7 ratio the Japanese Navy really wanted. This allowed Japan only 18 battleships to 30 for the U.S. and 30 for Great Britain instead of the 21 battleships Japan desired. This was the height of Yardley's cryptanalytic career.
Unfortunately, Yardley spent much of his time in New York involved in unrelated activities. Also, the flow of diplomatic telegrams dried up as companies became less willing to break the law to help the government. In Washington, William Friedman was actively exploring cryptographic frontiers for the Army. The Cipher Bureau was becoming irrelevant. However, it was moral indignation that finally doomed the bureau.
When Henry L. Stimson, Secretary of State under President Herbert Hoover, found out about Yardley and the Cipher Bureau, he was furious and withdrew funding, summing up his argument with "Gentlemen do not read each other's mail". Some believe that Stimson was most offended when Yardley bragged that he could read all traffic of the Vatican, for it was after this remark Stimson turned and left the room.
MI-8 closed its doors for good on October 31, 1929, just two days after the stock market crashed. With Yardley's esoteric skills in very low demand, he took up writing about his experiences in codebreaking to support his family. His memoirs, The American Black Chamber, were published by Bobbs-Merrill in 1931. The book outlined the history of the first U.S. Signals Intelligence (SIGINT) organization, described the activities of MI-8 during World War I and the American Black Chamber in the 1920s, and illustrated the basic principles of signals security.
This work was instantly popular. Its critics at the time concluded that it was "the most sensational contribution to the secret history of the war, as well as the immediate post-war period, which has yet been written by an American. Its deliberate indiscretions exceed any to be found in the recent memoirs of European secret agents." In the U.S., 17,931 copies were sold, with 5,480 more sold in the U.K. It was translated into French, Swedish, Japanese, and Chinese. The Japanese version sold an unprecedented 33,119 copies.
This book was an embarrassment to the U.S. government and compromised some of the sources Yardley and his associates used. Through this work an estimated 19 nations were alerted that their codes were broken. Much of the post-World War I codebreaking was done by obtaining copies of enciphered telegrams sent over Western Union by foreign diplomats, as was the custom before countries had technology for specialized communications devices. William F. Friedman, considered the father of modern American signals intelligence (SIGINT) gathering, was incensed by the book and the publicity it generated in part because sources and methods were compromised and because Yardley's contribution was overstated.
While Yardley may have thought that publishing this book would force the government to re-establish a SIGINT program, it had the opposite effect. The U.S. Government considered prosecuting him, but he had not technically violated existing law regarding protection of government records. In 1933, the Espionage Act was amended, PL 37 (USC Title 18, section 952), to prohibit the disclosure of foreign code or anything sent in code. Yardley's second book, Japanese Diplomatic Codes: 1921-1922, was seized by U.S. marshals and never published. The manuscript was declassified in 1979.
The American Black Chamberrepresents an early example of the exposé national security books that would appear after World War II, such as The Codebreakers and The Puzzle Palace, which also focus on U.S. SIGINT operations and organizations.
In 1935, Metro-Goldwyn-Mayer released Rendezvous, a fictional film "based on a book by Herbert O. Yardley." The film, starring William Powell and Rosalind Russell, and directed by William K. Howard, concerns a German spy ring stealing U.S. government codes during World War I, as well as U.S. Army efforts to crack German codes.
Yardley did cryptologic work for Canada (although pressure from the U.S. on the Canadian government meant this was limited) and China during World War II, but he was never again given a position of trust in the U.S. government. Despite this, in 1999 he was given a place in the National Security Agency Hall of Honor.
None of Yardley's many later attempts at writing were as successful as The American Black Chamber, though he published several articles and three spy/mystery novels (The Blonde Countess, Red Sun of Nippon, and Crows Are Black Everywhere). He contributed as a writer and technical advisor to several movies, including Rendezvous, based very loosely on one of his novels, The Blonde Countess. His 1957 book on poker, Education of a Poker Player, which combined poker stories with the math behind the poker strategies, sold well. Another book of cryptographic memoirs, The Chinese Black Chamber, about his work in China, was declassified and published in 1983.
Yardley died on August 7, 1958, nearly a week after having a major stroke. He is buried at Arlington National Cemetary, Grave 429-1 of Section 30.
Yardley is a member of the Military Intelligence Hall of Fame.
The National Cryptologic Museum's library has 16 boxes of Yardley's personal files.