Mr. Barr also said that companies that sell encryption with the goal of ensuring “that law enforcement will not be able to gain lawful access” are “illegitimate.”

Mr. Barr’s position echoed that of former Justice Department officials, including James B. Comey, the F.B.I. director, and Rod J. Rosenstein, the deputy attorney general, who took the lead on the law enforcement side of what has been a long-running tension with technology companies and champions of personal privacy.

Privacy advocates have long argued that law enforcement can get most of the information it seeks by subpoenaing technology companies for user records and other data, and that those companies do not need to create ways to break into their own encryption at the behest of the government.

The F.B.I. director, Christopher A. Wray, and other officials have long argued that strong encryption was hindering crime solving, previously citing a total of 7,800 mobile devices that investigators were kept out of in the fiscal year that ended in September 2017, even though the bureau had the legal authority to gain access to them.

But last year, the F.B.I. acknowledged that it had erroneously inflated the number of smartphones and other mobile devices it has been unable to open because of encryption, blaming a programming error.

Privacy advocates immediately attacked Mr. Barr’s speech.

“Encryption reliably protects consumers’ sensitive data,” said Brett Max Kaufman, a senior staff lawyer in the Center for Democracy at the American Civil Liberties Union. “There is no way to give the F.B.I. access to encrypted communications without giving the same access to every government on the planet. Technology providers should continue to make their products as safe as possible and resist pressure from all governments to undermine the security of the tools they offer.”

Mr. Barr is assuming that the negative impacts of encryption on law enforcement investigations “far outweigh encryption’s benefits for protecting individuals, business and the nation,” said Riana Pfefferkorn, the associate director of surveillance and cybersecurity at the Stanford Center for Internet and Society.