New Zealand has passed a law giving customs officials new powers to search travelers' phones.

Border agents are allowed to issue fines of up to 5,000 New Zealand dollars ($3,200) to anyone who refuses to hand over the information.

Rights groups say the new Customs and Excise Act 2018 is an invasion of privacy.

New Zealand can now fine travelers up to 5,000 New Zealand dollars ($3,200) if they refuse to hand over their phone password at the country's border.

The nation's Customs and Excise Act 2018, which came into effect this week, allows customs officials to demand "access information"— like passwords, PINs and encryption keys — and mandates fines for those who do not cooperate.

The legal text states: "If the person has no reasonable excuse for failing to comply with [handing over your password], the person commits an offence, and is liable on conviction to a fine not exceeding $5,000."

In order to demand a search, officials must have "reasonable cause" to suspect somebody of breaching customs laws or committing another crime.

However, the law means that officials can only access information stores locally on your phone, and does not give them access to information stored in the cloud with services like iCloud or Google Drive.

The new law was met with resistance from rights groups.

Thomas Beagle, the chairperson of the NZ Council for Civil Liberties said on Wednesday: "Modern smartphones contain a large amount of highly sensitive private information including emails, letters, medical records, personal photos, and very personal photos."

"Allowing Customs to be able to demand the right to examine and capture all this information is a grave invasion of personal privacy"

The New Zealand government says that the law balances of national security and personal privacy.

On Monday, New Zealand's Privacy Commissioner, John Edwards, was "pretty comfortable" with the changes to the law, Radio New Zealand reported.

"There's a good balance between ensuring that our borders are protected ... and [that people] are not subject to unreasonable search of their devices," Edwards said.