The weapon? A type of software known as ransomware.

The crime is as simple as it is mendacious. Victims typically receive an email with a link or attachment that contains software that encrypts files on their computer and holds them hostage until they pay a ransom. Many of the hackers who carry out such attacks operate in Russia and Eastern Europe, according to the police, and often demand a ransom in Bitcoin, a digital currency that is hard to trace.

“Ransomware is becoming a pandemic,” said Tony Neate, a former British police officer who investigated cybercrime for 15 years. “With the internet, anything can be switched on and off, from computers to cameras to baby monitors.”

Still, he added, “hacking a hotel and locking people out of their rooms is a new line of attack.”

Mr. Neate, now chief executive of Get Safe Online, a government-backed security charity in Britain, said that demands in ransomware schemes were usually low enough that victims would acquiesce. As a result, however, hackers waged dozens of attacks a day to make them financially viable.

He nevertheless counseled victims not to pay, arguing that that would only further encourage more attacks and that the funds used to pay the ransom would bankroll nefarious activity, including possibly terrorism. Hotels, he warned, should also guard against copycat crimes by reinforcing their digital security.

According to the United States Justice Department, ransomware attacks quadrupled in 2016 to an average of 4,000 a day. The F.B.I. said the costs to victims of such attacks rose to $209 million in the first three months of 2016, compared with $24 million throughout 2015.

It is a sign of the crime’s sinister proliferation that it has also entered popular culture.

In an episode of the legal drama “The Good Wife,” a Russian hacker attacked a law firm in the middle of a prominent case, encrypting its files and demanding a $50,000 ransom. The hacker eventually relented after the firm turned the tables by infecting the extortionist’s computer with propaganda criticizing Russia’s president, Vladimir V. Putin.

In the real world, however, many have been forced to pay up.

Last year, hospitals in California and Kentucky were targeted in ransomware attacks. In one case, a Los Angeles hospital paid more than $17,000 to hackers to restore its computer network, and all of its digital medical files. Other victims in Europe and the United States have included a municipal utility, companies, schools, law firms and police departments.