In 1975, a 30-year-old electrical engineering researcher at Stanford had an idea for a new kind of cryptography. He thought his method could give the public truly unbreakable codes for their communications and other data, codes even more powerful than those produced by the National Security Agency, the nation's premier code-making and code-breaking agency.

''I remember thinking, 'I've got a tiger by the tail,' '' said the scientist, Dr. Martin Hellman, now an emeritus professor of electrical engineering at Stanford. Sure enough, the N.S.A. soon stepped in and tried to control the dissemination of the work. The new technology could be so valuable to an enemy, the agency worried, that it should be classified at birth.

Dr. Hellman and others resisted. They said that the agency's threats to restrict them were violations of academic freedom, an unwarranted limitation on their right to publish and discuss new ideas. And they worried about the harm that could be done to national security if the technology were kept from the private sector, leaving its corporate data and private communications vulnerable to eavesdroppers, terrorists and hostile governments.

In the end, the academic scientists prevailed. They freely published their research on how to make codes. And companies soon sprang up to sell them.

But now, in the aftermath of the terrorist attacks on New York and the Pentagon, Dr. Hellman and others whose work spawned the commercialization of high-level cryptography are wondering if they did the right thing. They are haunted by the idea that law enforcement agencies may have figured out what the terrorists were planning, if only powerful encryption techniques had been kept secret.

And even if these particular terrorists relied on hand-delivered notes and other forms of communication not vulnerable to eavesdropping, what about other terrorists who might be lurking?

''Everything's changed,'' Dr. Hellman said.

When the technology was new, though, the issues looked clear-cut. Of course cryptography should be easily available to everyone, Dr. Hellman and other academic researchers argued. Twenty-five years ago, he said, ''I saw myself as Luke Skywalker and the N.S.A. as Darth Vader.'' Several years later, he said, ''in a period of deep personal introspection, I saw how human but how ridiculous that view was.''

But now, he said, with the country searching for terror suspects, the old questions have resurfaced with new force. ''I could say, I made exactly the right decision,'' he said, ''or I could say, If I could have envisioned this, I would never have published those papers.''

It probably is too late to take back cryptography even if people wanted to, experts say. But the ''what if?'' games of history can leave an indelible mark on today's debates over how, and whether, to control new technologies that can transform balances of power and be used for good and evil.

Already, arguments have begun over a very different science, nanotechnology -- the use of molecular machines to build structures atom by atom. At least one nanotechnology researcher, Dr. Ralph C. Merkle, started out in cryptography -- he worked with Dr. Hellman -- and so, for him, the new debate almost gives him a sense of déjà vu.

Nanotechnology could produce computers so powerful that today's machines would seem like clunky toys. And it could produce weapons with the power of a supercomputer embedded on the head of a bullet.

It could provide tiny robots to go into blood vessels and clean out plaque -- or microscopic robots that could kill instead of heal, and in ways far more predictable and precise than anything envisioned in germ warfare. One nanotechnology expert, Glenn H. Reynolds, a law professor at the University of Tennessee, said that someday it might even be used to make tiny robots that would lodge in people's brains and make them truly love Big Brother.

It is a technology whose consequences could be so terrifying that one scientist, Dr. K. Eric Drexler, who saw what it could do, at first thought that he should never tell anyone what he was imagining, for fear that those dreadful abuses might come to pass.

Scientists struggling with the promise and peril of nanotechnology say they look at the issues that arose with cryptography and see chilling parallels. Once again, they say, advances in technology are creating thorny moral issues. And once again, there are no easy answers on how to proceed.

The cryptography story unfolded in the years just after Watergate, when many academic scientists distrusted the federal government, and at a time when banks and other corporations were becoming concerned that their electronic data were insecure.

The academic scientists came up with a startling idea. Encryption is a way of scrambling data and, for quite some time, this has meant using mathematical formulas to transform data -- words or numbers, say, into strings of unreadable data. Dr. Hellman and Dr. Merkle, who now works for Zyvex, a nanotechnology company in Richardson, Tex., and Dr. Whitfield Diffie, a student of Dr. Hellman who now works for Sun Microsystems, decided to exploit ancient and unsolvable mathematical problems. If a code were designed so that anyone who wanted to break it would have to solve one of these problems, that code would be unbreakable.