Its main function is to protect the UK from terrorism and cyber attacks, but now GCHQ is set for its second foray into the rather less dangerous world of puzzlebooks.

The country’s top codebreakers have created a new set of brainteasers to mark the intelligence agency’s centenary year in 2019.

The GCHQ Puzzle Book 2 will be released on October 18, with hopes of repeating the success of the first edition in 2016.

Priced at £12.99, all proceeds from sales of the book will go to the Heads Together mental health campaign spearheaded by the Duke and Duchess of Cambridge and Duke of Sussex.

A GCHQ spokesman said: “We were delighted with the success of our first puzzle book, which raised over £330,000 for the Heads Together campaign, an important cause to change the conversation around mental health.

“To mark our centenary next year in 2019, we have created a new puzzle book celebrating our 100-year history of keeping the country safe.”

The book will feature a range of new puzzles, ranging in difficulty from easy to fiendishly difficult, as well as authentic entrance exams set for would-be recruits.

It will also include anecdotes about the people, technology and partnerships that are central to GCHQ’s mission.

Daniel Bunyard, of the book’s publisher Michael Joseph, said: “We couldn’t be more delighted to be publishing another book of puzzles from GCHQ, particularly as part of such a momentous anniversary for the organisation.

“The 2016 book was the Christmas stocking filler of choice and we’re hoping that this new batch will be as fun, mind-bending and rewarding as before.”