Police departments in midcoast and northern Maine said they have paid ransom to hackers to keep their computer files from being destroyed, WCSH-TV reported Friday night.

The Portland station said the Lincoln County Sheriff’s Office and four towns paid $300 to the hackers after a virus, called a “megacode,” was downloaded on a computer system they share. Lincoln County Sheriff Todd Bracket said that the computer system was unusable until the fee was paid, and that the hackers claimed the program, called “ransomware,” would wipe the entire computer system clean if the fee wasn’t paid.

The creator of the virus gave the sheriff’s office a code to unlock the computer system after the money was received. The county paid in bitcoins, an online currency.

“We needed our programs to get back online,” said Damariscotta Police Chief Ron Young. “That was a choice we all discussed and took to get back online to get our information.”

Brackett told WCSH that the FBI tracked the payment to a Swiss bank account, but no further.

The Houlton Police Department told the station that it was hit with a similar virus early this week and its computer system was locked up until ransom was paid.

Last summer, the FBI, foreign governments and private security firms dismantled an operation, based in Russia, that commandeered as many as a million computers and drew money out of bank accounts, The Washington Post reported. The operation also included a ransomware scheme and officials said they had identified the 30-year-old Russian behind the operation but had not apprehended him.