MI5 called him our “greatest unsung hero” for helping to defeat the Nazis from a little room on Dublin’s North Circular Road.

Limerick man Richard Hayes was director of the National Library of Ireland but decoded Nazi messages at the behest of Eamon de Valera.

4 During WW2, one of Nazi Germany’s most notorious communication codes was broken by a librarian and family man from West Limerick, Richard Hayes

A new RTE radio documentary reveals that in 1940 British intelligence agents detected illicit transmissions, known as cyphers, coming from Dublin.

It was Hayes who discovered that the Nazis were working out of the embassy at Northumberland Road.

Trinity College Professor Eunan O’Hailpin said: “The Irish don’t tell the British immediately because it creates a very difficult diplomatic problem.”

De Valera set up defence measures with his military, but he also believed that G2, Ireland’s army intelligence, could solve the code. G2 director Dan Bryan feared the Germans were gathering intelligence for an invasion.

4 McKee Barracks in Cabra, Dublin where Hayes worked from to help decode Nazi messages (Credit: Google Street View)

Hayes was given an office in McKee Barracks on North Circular Road and a covert job tackling the code that had flummoxed other intelligence agencies. Meanwhile, German spy Dr Herman Gortz parachuted into a field in Co Meath, ready to report back to Berlin.

He was to meet the IRA about its Plan Kathleen — the invasion of Northern Ireland by German troops. The plot was discovered by gardai who raided a safehouse in which Gortz was staying.

Gortz escaped but was arrested the following year and Hayes began to visit him in Arbour Hill Prison to try to crack the keycode the Germans were using.

Historian of Modern Britain Intelligence, Dr Chris Smith, said: “He is tasked, almost single handedly, to break this material. Hayes is effectively a one-man army in this context.”

4 Prime Minister Eamon de Valera, addressing the crowds at the United Front Rally Credit: Getty - Contributor

Hayes got his lucky break when he realised Gortz had been storing messages in his clothes to send when he got to a radio transmitter.

While the German prisoner was visiting a doctor over an ulcer, Hayes copied the documents from his clothes and replaced them.

Within months he had cracked the code and discovered the key words were “Cathleen Ni Houlihan”.

This discovery meant he was able to decipher what Gortz and the German intelligence services were saying to each other. This information was shared with the world’s intelligence agencies and helped them convince the Nazis that the allies landing on D-Day at Normandy in June 1945 was a decoy and that the real invasion would be launched near Le Harve as Hitler believed it would.

4 German Nazi leader Adolf Hitler on his way to deliver an oration at a party rally in Nuremberg, circa 1935 Credit: Hulton Archive - Getty

Richard Hayes, Nazi Codebreaker airs on RTE Radio 1 today at 2pm.