Thomas H. Dyer, 82, a retired Navy captain who as an expert cryptanalyst played a major role in breaking the Japanese naval codes during World War II and helping turn the tide of battle in favor of the United States, died Jan. 5 of cardiopulmonary arrest at the University of Maryland Hospital in Baltimore.

Capt. Dyer was in charge of the Navy's cryptanalytic unit at Pearl Harbor, Hawaii, during the war. In this role he was one of the leading figures in efforts that led to the decoding of the Japanese main fleet orders during the weeks before the battle of Midway.

He also helped direct the Navy's decoding of destinations, routes and timetables of Japanese merchant shipping, and the deciphering of the itinerary of Adm. Isoruku Yamamoto, the Japanese naval commander and one of the most brilliant strategists of the war. That breakthrough enabled U.S. warplanes to ambush and shoot down Yamamoto's plane over the Solomon Islands in the spring of 1943.

Capt. Dyer's "great service was that he saved hundreds and maybe thousands of lives by accelerating the war," David Kahn, a military historian, said in an interview. Kahn is the author of "The Codebreakers," a definitive history of allied code-breaking in the war.

"He and the other members of the code-breaking agencies are among the unsung heroes of the war. A lot of people who are alive today might not be, but for their efforts."

As a cryptanalyst, Capt. Dyer spent almost the entire war in the basement of a windowless building at Pearl Harbor. Although his work was vital, it was known to only a few ranking Navy officers and members of the intelligence community. Retired Navy Capt. W. J. Holmes recalled in a book, "Double-Edged Secrets," that Capt. Dyer's, wife, a resident of Honolulu who was not evacuated after the Pearl Harbor attack, would supply him with a picnic basket filled with sandwiches and that he would work round-the-clock for two or three days, then take a short break and return to work.

But his daughter, Ann Dyer of Washington, said she and her mother knew nothing of her father's accomplishments until more than 20 years later, when some of the information became declassified and historians began to write about it.

Kahn, who interviewed Capt. Dyer extensively for his book, described him as having "a mild and friendly personality with a tough and unrelenting mind."

Capt. Dyer was one of the first to use IBM tabulators to do the sorting and counting of digits that are essential to cryptanalysis, and Kahn called him the "father of machine cryptanalysis."

It was during the early months of World War II that Capt. Dyer's cryptanalysts began to unravel pieces of the Japanese main fleet code. By the spring of 1942 they had decoded enough to sketch the outlines of what appeared to be a Japanese plan to seize Port Moresby in New Guinea and threaten Australia.

Adm. Chester W. Nimitz sent two aircraft carriers, the Lexington and the Yorktown, to meet the Japanese thrust and the result was the Battle of the Coral Sea. The Lexington was sunk and the Yorktown heavily damaged, but the Japanese also suffered heavy losses. Although a tactical victory for Japan, the battle was considered a strategic victory for the United States and Japan was in no position to threaten Australia again.

In May of 1942, the cryptanalysts went to work on a message to the Japanese Combined Fleet that was so long that intelligence officers concluded it could only be an operations order. Eventually they narrowed it down to an order for an attack on Midway. As the Japanese fleet approached the island, the U.S. Navy knew more about its plans than most Japanese captains, Kahn wrote.

On June 4, 1942, the Japanese were attacked by aircraft from three U.S. carriers, the Hornet, the Enterprise and the Yorktown. Four Japanese carriers were sunk that day, marking what many consider to be the turning point of the war in the Pacific.

As a result of cryptanalysis, Army Chief of Staff Gen. George C. Marshall said, "We were able to concentrate our limited forces to meet their naval advance on Midway when otherwise we would almost certainly have been 3,000 miles out of place."

As a result of the breaking of the Japanese merchant shipping codes, sinkings by American submarines were said to have increased by one-third, and so accurate was the information relayed to submarine commanders, according to Kahn, that some complained whenever the Japanese ships were even a half hour late. "We were reading this in large measure through Dyer's work," Kahn said. After the war, Japanese leaders said the destruction of their merchant shipping was one of the major factor's leading to their nation's defeat.

The death of Yamamoto after his plane was shot down in 1943 "was the equivalent for the Japanese of Eisenhower being killed in the middle of the war," said Kahn. "It was the most spectacular single incident ever to result from cryptanalysis."

Born in Osawatomie, Kan., Capt. Dyer graduated from the U.S. Naval Academy in 1924. He began working in cryptology on his own initiative while serving aboard the battleship New Mexico. He was assigned to Pearl Harbor in 1936 and remained there until the war ended. He worked at the National Security Agency in Washington until he retired from the Navy in 1955 and then taught mathematics at the University of Maryland until his second retirement in 1967.

In private life, he gardened, raised orchids under lights, and did needlepoint. He lived in Hyattsville until 1980 when he moved to Sykesville, Md.

In addition to his daughter, Capt. Dyer's survivors include his wife, Edith M., of Sykesville, and three grandchildren. A son, Thomas Edward, died in 1981.