A former police sergeant has been held without charges in a federal detention cell in Philadelphia, part of an effort by the authorities to pressure him to decrypt two computer hard drives believed to contain child pornography.

The case reveals yet another battle line for law enforcement and digital privacy advocates over encryption, this time on an Apple computer, not an iPhone.

The sergeant, Francis Rawls, was ordered by a federal court in August to hand over the two hard drives, which were seized from his home because they were suspected to contain the illegal pornography.

Rawls was shown to a private room at the district attorney’s office to comply with the order. Once there, according to a court document, he spent most of the time staring at the computer and then said he could not remember the passwords to turn off FileVault, a feature of Macs that encrypts hard drives when a user logs out. He was taken into custody, and this week he started his eighth month in a federal detention center, all without ever being charged with a crime.

Rawls’ case is the latest in a growing number of legal battles over digital privacy in the United States. The challenges are playing out in courts across the country, propelling a national debate over when the government can compel individuals or companies to disclose codes or passwords giving access to private data.

“Not only is he presently being held without charges, but he has never in his life been charged with a crime,” Keith M. Donoghue, his federal public defender, wrote in a motion last week seeking his client’s release.

In two high-profile cases recently, the Justice Department tried to force Apple to unlock an iPhone used by a gunman who was behind the massacre in San Bernardino, California, and an iPhone used by a Brooklyn drug dealer. The department later backed off after it accessed data on the phones without the company’s help.

Mark Rumold, a senior lawyer with the Electronic Frontier Foundation, a nonprofit group that focuses on defending civil liberties in digital issues, said the increased focus on privacy rights was spurred in 2013 by Edward J. Snowden’s revelations about government surveillance, which led to the pursuit of more advanced encryption technologies to counter that surveillance.

“It is a combination of a growing awareness and increased use of technologies that are privacy protected,” Rumold said. “I do not think it is a stretch to say these types of issues are affecting people all over the country in everyday life.”

Encryption goes further than a simple login password, by scrambling data in a way that requires a password key to descramble it. It is used most commonly to protect consumers from online fraud or to keep bank accounts secure.

Law enforcement agencies have typically made encryption an issue in high-profile cases involving terrorism or child pornography. In March, President Barack Obama said the United States had already accepted that law enforcement can “rifle through your underwear” in the search for suspected predators, so there was no reason to treat a person’s digital information differently.

If the government has no way into a smartphone, he added, “then everyone is walking around with a Swiss bank account in your pocket.”

Many of the cases involving court-ordered access to personal devices include arguments centering on an individual’s right under the Fifth Amendment against self-incrimination, and about whether they can be compelled to reveal passwords or decrypt those devices.

In the Philadelphia case, for example, the officer was told to type in the passwords in a private room in the district attorney’s office, rather than to simply tell the password, which could be construed as testifying against himself.

Suspects may be on shakier constitutional grounds when it comes to biometric data like fingerprints.

In another recent case, the authorities in California obtained a search warrant in February compelling the girlfriend of a suspected member of an Armenian gang to press her finger against an iPhone that had been seized from a Glendale home. The phone was protected by Apple’s fingerprint identification system, and prosecutors wanted access to the phone data, according to a Los Angeles Times report.

In some cases, courts have said that ordering suspects to decrypt their own devices for investigators violated their rights, such as in the 2013 case of a Massachusetts forgery suspect. But when the case later made its way to the Massachusetts Supreme Judicial Court, that decision was reversed.

In his motion to a federal court of appeals last week, Donoghue, the Philadelphia public defender, said his client, whom he referred to as John Doe, had come under scrutiny during a Delaware County investigation into a public network called Freenet, where users communicate and share files in a secure environment.

The two hard drives and other devices, including an Apple Mac Pro computer, were seized from Rawls’ home on March 30, 2015. After he did not decrypt the hard drives, he was ordered in September to be “incarcerated indefinitely” until he complied with the order, not to “punish him,” but to “coerce future compliance,” prosecution documents said.

He was taken into custody by U.S. marshals. The Philadelphia Police Department said in October that Rawls, who had been on the force for 17 years, would be suspended and then dismissed for “conduct unbecoming” an officer.

Last week, Donoghue said in his motion to the court that the detention was causing “irreparable injury” to a man who had not been charged with any crime and who was exercising his right not to provide evidence that might be used against him.

“We are hopeful the appeal will result in our client’s prompt release from the custody that was ordered after he invoked his Fifth Amendment right against self-incrimination,” Donoghue said in an emailed reply to questions.

Parts of the court documents that would explain the reasons for Rawls’ detention and the court order are still under seal. Government prosecutors have until May 16 to reply.