The head of GCHQ has spoken with regret of the treatment of Alan Turing, the second world war codebreaker and mathematical genius, who killed himself in 1954, two years after being convicted of homosexuality, which was then a criminal offence.

In a rare speech to mark the centenary of Turing's birth, Iain Lobban said the unique people the country needed were often mavericks, and it was his job to set them to work in the world of secret intelligence, "not to tell them how to live their lives".

Lobban told an audience in Leeds that Turing was a national asset whose death robbed the country of "one of our greatest minds". He said more people like Turing were needed if Britain was to stay ahead of the challenges and dangers posed from cyberspace.

"We can't rewrite the past," he said. "We can't wish mid-20th century Britain into a different society with different attitudes. We can be glad that we live in a more tolerant age. And we should remember that the cost of intolerance towards Alan Turing was his loss to the nation."

In 2009 the then prime minister, Gordon Brown, apologised for the treatment and vilification Turing received.

Turing was a central member of the team at Bletchley Park, the code-breaking centre that played a significant role during the 1940s, unravelling encrypted communications used by the Nazis. He also developed a machine that arguably became the model for the modern computer.

Lobban, who has been head of GCHQ, the government's electronic intelligence-gathering centre, for four years, described Turing as "a founder of the information age … One of the people whose concepts are at the heart of a technological revolution which is as far-reaching as the industrial revolution."

He added: "And of course there are many Turing stories: burying his silver bullion and then forgetting where he had buried it; chaining his mug to his radiator; cycling in his gas mask to ward off hay fever.

"But Turing was not an eccentric, unless you believe that there is only one way of being normal and to be otherwise is to be peculiar. Turing wasn't eccentric. He was unique."

Lobban insisted today's GCHQ needed more people like him. "I strongly believe [the] agency needs the widest range of skills possible if it is to be successful, and to deny itself talent just because the person with the talent doesn't conform to a social stereotype is to starve itself of what it needs to thrive.

"Part of my job is to continue to foster that atmosphere: to attract the very best people and harness their talents, and not allow preconceptions and stereotypes to stifle innovation and agility. I want to harness the best talent … so that they can apply themselves to the big issues of intelligence and security which challenge an organisation which simply has to remain at the cutting edge in order to survive and thrive.

"I want to apply and exploit their talent. In return, I think it's fair that I don't need to tell them how to live their lives."

Lobban said GCHQ needed to "reach beyond the university level. We must inspire schoolchildren to study maths and science. We must find tomorrow's Turings."

He said that if Turing was alive now, he would be working to secure the UK's interests in cyberspace.

"Then, the technological challenge was to stay ahead of the Germans. Today, our challenges come from the explosion in the volume of communications as well as the relentless increase in new ways of accessing and processing it.

"Then, the challenge was to secure allied codes and ciphers to prevent the enemy doing to us what we were doing to them. Today, [it is] securing cyberspace so the UK … can use it safely to develop e-government and trade."

Lobban also used the speech to explode some of the myths about Bletchley Park, particularly regarding the Enigma machine, which was used by the Nazis to encrypt messages.

"You have probably all seen the Hollywood version of the Enigma story," he said. "The films showing heroic sailors leaping onto sinking German submarines to recover their Enigma machines. The truth around the initial acquisition is a little more prosaic. In 1926, Edward Travis, who later became director of GCHQ, went to Berlin and obtained an Enigma machine by the simple expedient of going to the manufacturing company and buying one."