"Was it worth it?" That was what Julian Assange was asked, through his mother, by an Australian TV channel last week as he sat in Wandsworth jail. It was, perhaps, a not unexpected question for someone who had found himself in solitary confinement, facing extradition to Sweden and the United States and death threats from conservative American politicians.

So do people whose revelations about secret government activities reverberate around the world, and who find themselves pursued and vilified as a result, live to regret their actions?

More than 30 years ago Philip Agee, then a 41-year-old former CIA officer living in Cambridge, was told that he was to be deported from Britain as a threat to the security of the state. He had published a damaging exposé of the CIA, Inside the Company, and had made clear his intent to reveal the identities of CIA agents. In Britain he worked with publications such as Time Out to name the agents, leading to many of them being sent back to Washington, their cover blown. The US government vowed vengeance.

Agee wept on the ferry that took him from Britain after his deportation in 1977, but remained unrepentant right up to his death in 2008. He had been motivated initially by his horror at the backing given by the CIA and US government to Latin American military dictatorships. Reflecting years later on what he had done and the damage it has caused to him and his young family, Agee told me: "There was a price to pay. It disrupted the education of my children and I don't think it was a happy period for them ... But it made me a stronger person in many ways, and it ensured I would never lose interest or go back in the other direction politically. The more they did these dirty things, the more they made me realise what I was doing was important."

Under the US Freedom of Information Act, Agee was able to see the scope of the operation mounted against him by an unforgiving CIA which accused him through the media of being a boozer and a womaniser. "They admitted to having 18,000 pages on me. I figured out there were 120 pages a day for seven or eight years."

He was, like WikiLeaks, accused of endangering lives. The name of Richard Welch, the CIA station chief in Athens assassinated in 1975, was often invoked. He was named, however, not by Agee but in other publications. "George Bush's father came in as CIA director in the month after the assassination and he intensified the campaign, spreading the lie that I was the cause of the assassination."

Agee's fellow American, Daniel Ellsberg, also faced prison and death threats after his leaking in 1971 of 7,000 pages of Pentagon documents, which is credited by many with helping to end the Vietnam war. "Let's get the son of a bitch into jail," President Nixon was recorded as saying to his henchmen in what sounded like a Mafia confab. "We've got to get him," Henry Kissinger, then secretary of state, replies. "Don't worry about his trial," says Nixon. "Try him in the press."

Ellsberg, too, remains unbowed and is active today on behalf of other whistleblowers and leakers. In the preface to his book, Secrets: a Memoir of Vietnam and the Pentagon Papers, he writes: "Telling the truth, revealing wrongly kept secrets, can have a surprisingly strong unforeseeable power to help end a wrong and save lives."

Not everyone who decides to leak manages to escape the harsher penalties. Mordechai Vanunu, the technician who leaked details of the Israeli nuclear weapons programme to the Sunday Times in 1986, was pursued to England, lured to Italy by a female Mossad agent, kidnapped, and jailed for 18 years, and spent 11 in solitary confinement. He also remained convinced that he had done the right thing. If he has regrets, it is about the way he chose to leak the story.

"It was a mistake to go with one newspaper, but I didn't have any experience with the media," he said in an interview in Jerusalem after his release; significantly, WikiLeaks worked with five separate publications in five different countries. "My target was to bring information to the world, so the best way would have been a press conference or to send it to 20 newspapers so that it would not be controlled by anyone. Now things have changed and the internet has made it much easier for information to be passed on."

Vanunu had plenty of opportunities to decide whether it was all worth it. "There was a lot of pressure, a lot of attempts at brainwashing," he said. "I decided from the beginning that they could have my body in prison but my spirit, mind, brain, I would keep free, under my control; that would be my way out."