The Prince of Wales has paid tribute to the “utterly essential” work of staff at GCHQ during a visit to the agency’s headquarters.

Charles went to the Cheltenham base of GCHQ, nicknamed the Doughnut, as part of the centenary celebrations for the UK’s intelligence, security and cyber agency.

He toured the building with Jeremy Fleming, the director of GCQH, met staff from across the organisation and received a number of top secret briefings.

The Prince of Wales, as Patron of the Intelligence Agencies, talks with the GCHQ historian Tony Comer during a visit to the Government Communications Headquarters
The Prince of Wales addresses GCHQ staff (Peter Nicholls)

In a speech to staff, Charles, who is patron of GCHQ, MI6 and MI5, said: “The work you do is utterly essential.

“Its very nature means that your achievements are rarely made public and that few people in this country will ever know just how great a debt we all owe you.

“But for those privileged enough to understand something of what you do, the difference you make to our security, our prosperity and to the defence of our values is both clear and invaluable.”

He added: “To you, walking in past the razor wire each day becomes routine.

“But I hope that you will never lose sight of the fact that you are part of an extraordinary world-leading organisation that has achieved remarkable things during its proud 100-year history and which will continue to play an indispensable role over the century to come.”

Charles told staff he appreciated the challenges and pressures they face and highlighted “iconic names” such as Alastair Denniston, Alan Turing and Dilly Knox.

“GCHQ’s true genius lies in the power of its teamwork, collective innovation and shared knowledge,” he said.

“Each and every one of you has a part to play in writing the next chapter of GCHQ’s history – you quite literally are its future.”

After arriving at GCHQ, Charles met representatives from local charities the agency supports such as the James Hopkins Trust, Sue Ryder and Gardens for All.

He met members of Girlguiding South West England, which has launched a Cyber Security badge to increase awareness of the need to stay safe online.

Charles receiving top secret briefings in GCHQ’s 24/7 operations centre, where work including counter-terrorism, talking serious organised crime, online sexual predators and monitoring state activity takes place.

He delivered his speech before visiting the GCHQ museum to view a number of items relating to the agency’s work to protect members of the royal family.

These included a codebook developed for the royal household in 1939 and a Royal Navy codebook to set up a secure communications path when Charles was serving at sea.

The Prince of Wales, as Patron of the Intelligence Agencies, talks with the GCHQ historian Tony Comer
Charles meets GCHQ historian Tony Comer (Peter Nicholls/PA)

Tony Comer, GCHQ’s historian, showed photographs of Lord Mountbatten visiting GCHQ before opening a file of top secret intelligence reports for Charles.

Mr Comer, 61, who has worked for the agency for the past 35 years, showed Charles an encryption device called Noreen from the Royal Yacht Britannia.

“I’m so glad you kept this,” Charles said.

There are more than 6,000 staff working at GCHQ, which was officially opened by the Queen in 2004.

She has visited the agency three times, with Charles paying a number of private visits before Friday’s event.

Earlier this year, it emerged Prince William had spent three weeks on work placements with MI5, MI6 and GCHQ.

Mr Comer described such visits as “rare” and said they meant a lot to those working at the agency.

“Much of what is written about us is pretty negative and ill-informed,” he said.

“People speculate about what we do but they haven’t got a clue.”

Charles watches a Red Arrows flypast during a visit to the Government Communications Headquarters
The prince watches a Red Arrows flypast with Jeremy Fleming (Jacob King/PA)

After the museum, Charles went outside with Mr Fleming to watch the Red Arrows perform a flypast over the site.

Mr Fleming said: “This was an opportunity to say thank you to our brilliant workforce who, over the last century, have saved countless lives, shortened wars and solved some of the world’s hardest technology challenges.

“It was also a chance to look to our future – to the unprecedented rate of change and extraordinary opportunities of the digital age.

“We’re making the most of GCHQ’s unique talents to create a new kind of security and intelligence mission fit for our second century.”