The head of Britain's digital espionage agency has apologized for the organization's historic prejudice against homosexuals, saying it failed to learn from the treatment of World War II codebreaker Alan Turing.

GCHQ chief Robert Hannigan told a gathering organized by the human rights group Stonewall that a ban on homosexuals had caused long-lasting psychological damage to many and hurt the agency because talented people were excluded from service.

Hannigan said that while the ban was in place for decades and the policy was changed in the 1990s "it does not make it any less wrong and we should apologize for it."

Turing, a computer science pioneer and architect of the effort to crack Nazi Germany's Enigma cipher, was convicted of indecency in 1952 and later committed suicide.