Mavis Batey was a British student of 19, midway through her university course in German Romanticism, when she was recruited for a top-secret assignment during World War II.

“This is going to be an interesting job, Mata Hari, seducing Prussian officers,” she recalled thinking years later. “But I don’t think either my legs or my German were good enough because they sent me to the Government Code and Cipher School.”

In May 1940, Mrs. Batey — then the unmarried Mavis Lever — joined the team of code breakers at Bletchley Park, the British cryptography headquarters. Trained in the enemy’s language and endowed with a facility for words, she became a key contributor to a wartime project that remained classified for decades.

But by the time of her death on Nov. 12 at 92, Mrs. Batey was regarded in England as a national heroine. Working with Alfred Dillwyn “Dilly” Knox and other celebrated code breakers, she learned to decipher what she called the “utter gibberish” of encrypted German communications.

Battling the Enigma

Like many of her colleagues, Mrs. Batey worked on a “need-to-know” basis and did not understand at the time the significance of her efforts. In recent years, with the release of British wartime records, it was revealed that her code-breaking helped the Allies cripple the Italian navy in 1941 and assisted the 1944 Normandy invasion.

Mavis Batey was celebrated for her code-breaking work in England during World War II. (Bletchley Park Trust)

Winston Churchill, Britain’s wartime prime minister, was said to have called the Bletchley Park code breakers his “geese that laid the golden eggs but never cackled.” Fueled by what Mrs. Batey described as “ersatz coffee,” they toiled in secrecy to decipher the encoded messages spat out by the Axis powers’ Enigma machines.

Mrs. Batey recalled reporting for duty at Bletchley Park, a Victorian estate about 50 miles north of London, and being “thrown in at the deep end.”

“No one knew how the blessed thing worked,” she once told an interviewer, referring to the Enigma, which resembled a typewriter and scrambled messages with confounding complexity.

Knox, by her description, was an “eccentric genius” so consumed by his work that on at least one occasion, he stuffed his pipe with bits of sandwich rather than smoking tobacco.

“He would ask, ‘Which way does the clock go round?’ ” Mrs. Batey recalled in an interview with the Daily Telegraph. “If you were stupid enough to answer ‘clockwise,’ he would always answer, ‘Not if you’re the clock!’ That summed it up: You had to be prepared to think in a different way.”

Mrs. Batey’s first major contribution came in March 1941, when she helped decipher Italian naval communications revealing an impending attack on British ships ferrying supplies from Egypt to Greece. One message declared the arrival of “day X minus 3.”

“Why they had to say that I can’t imagine,” Mrs. Batey later said, according to the Telegraph. “It seems rather daft, but they did.”

She was the cryptographer on duty to decode a subsequent message explaining in excruciating detail the Italian battle plans. The information was passed to Adm. Andrew Cunningham, the commander of Britain’s Mediterranean fleet, who was then in Alexandria, Egypt.

Shortly before the attack, the admiral arranged to be spotted by a consul of the German-allied Japanese government. Cunningham, who knew that the consul enjoyed golf, showed up with his clubs and a valise, leaving the Japanese to believe that a weekend of leisure awaited him.

Instead of golfing, Cunningham led the British in a preemptive attack on the Italian navy. That encounter, the Battle of Cape Matapan, was a decisive victory for the British and effectively devastated the Italian fleet for the rest of the war.

The code breakers, Mrs. Batey recalled, shared two bottles of wine in celebration.

Abwehr and ‘dirty words’

Mrs. Batey also helped crack the even more complex Enigma codes employed by the Abwehr, the German military intelligence service. Some decoders were trained in mathematics and approached cryptography from a technical perspective. Mrs. Batey worked differently.

“I used the psychological approach,” she told the Telegraph. “To test the day’s settings, the Germans sometimes used their girlfriends’ names and dirty words; it was a great shame when they were stopped, as we enjoyed the dirty words.”

By penetrating Abwehr communications, Mrs. Batey and her colleagues helped confirm the success of the XX, or Double-Cross, an anti-espionage operation in which captured Nazi spies were used to transmit false information to the Axis.

The deceptive tactics were used throughout the war — most notably to fool Germans into believing that the D-Day invasion would take place not in Normandy, but at the Pas-de-Calais. Bletchley Park decoders confirmed that the ruse had worked and that the Allies could count on the relative security of their plan.

Mrs. Batey steadfastly emphasized the heroism of others, including Polish code breakers who had made significant contributions, and the “chaps” who stormed the beaches of Normandy.

“When my local paper came to interview me,” she once told the London Independent, she told the reporter: ‘I don’t want to see a headline saying ‘Bognor Regis Woman Won the War.’ ”

Mavis Lilian Lever was born in Dulwich, in south London, on May 5, 1921. (She later lived in the community of Bognor Regis.) Her father was a postal worker, and her mother was a seamstress.

During the war, she was studying at the University College London when she was approached for linguistic intelligence work.

“I think what clinched it for me,” she later told the London Daily Mail, “was that during my assessment they told me they had been puzzling over what the letters STGOCH stood for. While they wondered if there might possibly be a saint called Goch, I had the idea that the answer might be Santiago, Chile, which it was.”

Among her first assignments, according to the Telegraph, was poring over personal ads in the Times of London in search of secret German messages. On the basis of her performance, she was dispatched to Knox’s team at Bletchley Park. Her exploits later helped inspire the 2001 film “Enigma” starring Kate Winslet.

Mrs. Batey died at her home in West Sussex, England, according to the Bletchley Park Trust. The cause was not immediately available.

After the war, Mrs. Batey began a second career as a landscape preservationist. She was regarded as the doyenne of English garden historians and wrote books on horticulture.

Her literary output was not limited to that subject, however, and included “Jane Austen and the English Landscape” (1996), “The World of Alice,” about Lewis Carroll’s heroine (1998) and “Dilly: The Man Who Broke Enigmas” (2009).

At Bletchley Park, Mavis Lever met a mathematician, Keith Batey, whom she married in 1942 and who died in 2010. They had two daughters and a son, Elizabeth, Deborah and Christopher, all of whom survive.

The children grew up knowing nothing of their parents’ wartime employment, Mrs. Batey recalled, although “they were rather suspicious that we could always beat everybody at Scrabble.”