WASHINGTON — In their years together as top national security officials, Michael V. Hayden and Michael Chertoff were fierce advocates of using the government’s spying powers to pry into sensitive intelligence data.

Mr. Hayden directed a secret domestic eavesdropping program at the National Security Agency that captured billions of phone records after the attacks of Sept. 11, 2001. Mr. Chertoff pushed for additional wiretapping and surveillance powers from Congress both as a top prosecutor and as Homeland Security secretary.

But today, their jobs have changed, and so, apparently, have their views on privacy. Both former officials now work with technology companies like Apple at a corporate consulting firm that Mr. Chertoff founded, and both are now backing Apple — and not the F.B.I., with which they once worked — in its fight to keep its iPhones encrypted and private.

They are among more than a half-dozen prominent former national security officials who, to varying degrees, have supported Apple and the idea of impenetrable “end-to-end encryption” during a furious national debate over the balance between privacy and security in the digital age.