When a movie about J Edgar Hoover was released last year, it seemed as if the founder of the FBI were a character from a long forgotten era. Hoover ran the Federal Bureau of Investigation in the US for 37 years until 1972, turning it into a personal power base which he used to intimidate - even blackmail - the Washington elite.
He amassed compromising files on congressmen, governors and even presidents and would discreetly let them know, so that his budgets went unchallenged and he could pursue a bureaucratic war with the CIA - the Central Intelligence Agency - which he believed to be full of "phonies" and communists.
The impression given by the film J. Edgar, was that such abuse of power was as old-fashioned as Hoover's three-piece suits. But some question whether the era of the super-snooper, far from disappearing, has quietly returned in digital format. Since the September 11 attacks, the US has spawned a giant counter-terrorism bureaucracy, which may include 800,000 people with top-level security clearance, to intercept, store, decrypt, translate and analyse electronic communications.
The resignation of David Petraeus, America's most celebrated general of modern times, as director of the CIA has revived questions about the power of the FBI. That the FBI's latest scalp is that of the chief of the organisation against which Hoover waged war for so many years is just one worrying aspect. The distrust between the Bureau and the Agency was one of the causes of the intelligence failure that allowed the September 11 attacks to take America by surprise.
There is much we do not know about the scandal that brought Gen Petraeus's glittering career to an end. Suffice it to say that the man whose drive and political skills convinced Americans - in defiance of the evidence - that they won the Iraq war was brought low by a cheap drama of suburban jealousy.
He might just have survived the revelation of an adulterous affair with his biographer, Paula Broadwell, a reserve army officer with a high security clearance. But once Ms Broadwell started sending anonymous emails to a well known socialite - and supposed love rival - in Tampa, Florida, and the interest of the FBI's Cyber Division was aroused, there was no future for him.
The FBI itself had decided that there was no evidence of Gen Petraeus having committed any crime, but the agent who was first alerted to the email harassment thought differently. He apparently believed the FBI was burying the issue to protect President Barack Obama from embarrassment ahead of the November 6 election.
Behind this is a suspicion harboured by many Republicans that the CIA and the Obama administration are guilty of trying to cover up the truth of the recent attack on the US consulate in Benghazi, Libya, in which the ambassador, Chris Stevens, died. In the eyes of some Republicans, the combination of CIA, sex and cover-up would have exploded on the election campaign as the ultimate October surprise.
The FBI agent, identified by The New York Times as a veteran who was "obsessed" with the case but not actually involved in the investigation, alerted a congressman in Washington and the story which might have remained in Tampa was then in the national political domain. But it did not emerge until after the election.
The FBI director, Robert Mueller, will now have to do a lot of explaining. How can the famously disciplined FBI allow one agent to decide what is best for America, and in the process destroy the career of Gen Petraeus?
Mr Obama has left the FBI dangling. He said he has seen no evidence of any breach of security in the relationship between Gen Petraeus and Ms Broadwell. In a less-than-fulsome endorsement of the Bureau, he added: "I have a lot of confidence, generally, in the FBI."
The parallels with the Hoover era should not be pushed too far. Mr Mueller is no blackmailer. Since taking over in 2001 he has worked hard to improve cooperation with the CIA and other agencies, a labour that may now start to unravel.
There's another big difference: in Hoover's time this information would have been kept secret, so that the director could use it to manipulate the CIA chief. That it is being openly discussed is some progress.
This does not detract from the issue of how to control the treasury of data that the federal government agencies have stored on everyone who uses email, and prevent it being used for political advantage. In the polarised world of Washington politics, one man's rogue agent is another man's whistle-blower.
If there is one lesson that emerges from this it is that no one's electronic communications are safe. Gen Petraeus used an old trick to stay below the radar but not even the director of the CIA can beat the cyber snoopers: the general and Ms Broadwell did not send emails. They wrote messages and saved them in the drafts folder of a Gmail account for which both had the password.
But this was not enough to put the FBI off the scent. Nor was the FBI deterred from expanding the investigation to include thousands of emails between Gen John Allen, Gen Petraeus's successor in Afghanistan, and the Tampa socialite who set off the investigation by complaining of internet harassment. According to the FBI these emails contain "inappropriate" language. If this language is found to be nothing more than "sweetheart" we will know the FBI still lives by the prurient Puritanism of Hoover's generation.
Ultimately it is up to US public opinion to set tighter limits on who can access their emails. But people around the world are cavalier with their personal details online.
Every day, according to the American Civil Liberties Union, the National Security Agency intercepts and stores 1.7 billion emails, phone calls, texts and other electronic communications that can be accessed without the authority of an independent judge. The Petraeus affair should serve as a warning by demonstrating how easily the privacy of our communications is penetrated and how information can be used.
On Twitter: @aphilps