WASHINGTON—When Attorney General William Barr returned to the Justice Department last year, law-enforcement officials briefed him on how encryption and other digital-security measures were hindering investigations into everything from child sex abuse to terrorism.

Mr. Barr was surprised and puzzled, according to people familiar with the meeting. The government was struggling with similar problems when he first served as attorney general nearly 30 years ago, he told advisers. Why had they not been solved?

...