WISCASSET, Maine (NEWS CENTER) -- Police departments in the Midcoast and Aroostook County have learned a hard lesson over the past few weeks after their own computer systems were taken over by a virus.

Lincoln County Sheriff Todd Brackett said four towns and the county have a special computer network to share files and records. Someone accidentally downloaded a virus, called "megacode", that put an encryption code on all the computer data.

The Sheriff said it basically made the system unusable, until they paid a ransom fee of about $300 to the creator of the virus. After the fee was received, the department was given a special code to unlock the encryption and restore the files. The Sheriff and Damariscotta Police Chief Ron Young said no one liked having to pay off the bad guy, but it was the only way to get their information back.

"We needed our programs to get back online," said Young, "and that was a choice we all discussed and took to get back on line to get our information."

This type of virus is known as ransomware. It's becoming more and more frequent and other law enforcement departments across the country have had to pay up in order to receive their files. The hackers, which are commonly from Russia, often demand the ransom be paid in bitcoins, which is an online currency with a fluid value. The ransomware often says that if it is not paid within a certain amount of time, it will wipe the entire computer or system clean.

Brackett said they made a bitcoin payment and the FBI tracked the money to a Swiss bank account, but could go no farther.

And those Midcoast departments aren't the only law enforcement victims. The Houlton Police Department was also hit by the same or similar virus early this week, and it locked up all their files. Chief Terry McKenna said they, too, were forced to pay the ransom to get their computer data restored.

The best way to avoid this type of virus is to not download any suspicious looking attachments. If you've fallen victim to ransomware, you can file a complaint with the The Internet Crime Complaint Center.