Travelers entering New Zealand who refuse to disclose passwords for their digital devices during forced searches could face prosecution and fines of more than $3,000, a move that border officials said Tuesday made the country the first to impose such penalties.

“We’re not aware of any other country that has legislated for the potential of a penalty to be applied if people do not divulge their passwords,” said Terry Brown, a New Zealand Customs spokesman. Border officials, he said, believe the new fine is an “appropriate remedy” aimed at balancing individuals’ privacy and national security.

In New Zealand — as in many other countries, including the United States — customs officers were already legally permitted to search cellphones and other digital devices as they would luggage, and to seize devices for forensic examination if they were believed to contain evidence of criminal activity.

But the law did not previously compel travelers to open their devices for inspection, either by entering a password or using biometric data like thumbprints or facial scans.