Gen. Michael Hayden served as director of the U.S. National Security Agency, then as head of the CIA before backing encryption. Reuters/Larry Downing

Banning encryption is not the solution to defeating the Islamic State group or preventing so-called lone wolf attacks inside the United States, Gen. Michael Hayden, former director of the U.S. National Security Agency and the CIA, said Friday at a conference. The kind of legislation advocated by top U.S. law enforcement officials and various lawmakers would only make Americans' data less secure, while doing little to stop terrorist communications.

Hayden was referencing congressional bills that would make it illegal for technology companies to insert advanced cryptography into consumer products. Encyption like the passcode on Apple's iPhone and security used to protect WhatsApp messages in transit make it impossible for law enforcement to obtain the contents of a suspect's communication, even with a court order. FBI Director James Comey and Sen. Dianne Feinstein, D-Calif., are among those who have suggested anti-encryption legislation after terrorist attacks in Paris and San Bernardino, California, despite murky evidence encryption was used in either incident.

“Rather than restructuring our society we need to restructure what's going on out there,” Hayden said Friday, referring to increased U.S. military action against ISIS. “If I was in Jim Comey's position I would have the same point of view, but this is more of a law enforcement issue than an intelligence issue. The reality is that even if you legislate against [encryption] in the U.S., it doesn't stop it from happening.”

Hayden served as director of the NSA from 1999 until 2005, during which period he served as one of the key architects of the post 9/11 surveillance programs that helped instigate the pro-encryption movement that's taken hold of big tech. His remarks came on the same day Apple CEO Tim Cook reaffirmed his support for encryption, saying “I don’t believe that the trade-off here is privacy versus national security. I think that’s an overly simplistic view. We’re America. We should have both.”

Hayden, who now works as a security consultant for the Chertoff Group, made his comments in New York at a Council on Foreign Relations conference where he and Rob Bonner, former commissioner of U.S. Customs and Border Protection, agreed the San Bernardino mass shooting, where 14 people were killed, resembled an al Qaeda attack more than an ISIS one. Syed Farook, one of the shooters, appears to have been radicalized as early as 2007, and may have been inspired by the online sermons of Anwar al-Awlaki, the U.S.-born al Qaeda propagandist who was killed in a 2011 drone strike.

“The government still needs to prioritize large-scale terrorist attacks, like the Paris attack or what happened in Mumbai or Madrid, involving half a dozen or more well-trained foreign fighters,” Bonner said. “At the end of the day, no matter how good the FBI is, if you're talking about lone wolves who have been radicalized and are trying to kill people, that's going to continue to happen.”

Both Bonner and Jamie Gorelick, a former deputy attorney general, disagreed with Hayden on encryption. Gorelick advocated more mature cooperation with Google, Facebook and other U.S. companies that create products used by the entire world.

“I think we are, surprisingly for the country that invented social media, not good at using it or checking it,” Gorelick said. “Our national security sits on a bed of private companies, but we don't protect them and we don't utilize them in any real way. We talk a lot about public and private partnerships, but we've been miserable at it.”