Apple will appeal a California judge’s order to help prosecutors unlock an encrypted iPhone used by one of the San Bernardino shooters, with CEO Tim Cook saying the move would compromise customer security.

Cook confirmed the company’s position in an open letter posted on Apple’s website Wednesday, saying that “the U.S. government has asked us for something we simply do not have, and something we consider too dangerous to create”.

“They have asked us to build a backdoor to the iPhone,” he added.

On Tuesday at the US District Court in Los Angeles, US Magistrate Judge Sheri Pym issued a 40-page statement requiring Apple to give "reasonable technical assistance" to the FBI.

Prosecutors are seeking special software needed to bypass encryption and a self-destruct feature built into an iPhone owned by San Bernardino County and used as a work phone by Syed Rizwan Farook, one of the attackers in the December 2 San Bernardino mass shooting.

The judge gave Apple five days to show that the order is “unreasonably burdensome” - a new stipulation in the dispute between national security and digital privacy advocates.

Cook argues that the ruling threatens the security of Apple customers: “We oppose this order, which has implications far beyond the legal case at hand.”

He insists Apple has supported the FBI in the San Bernardino case, but is drawing the line at the creation of “backdoor” access to iPhones:

“Specifically, the FBI wants us to make a new version of the iPhone operating system, circumventing several important security features, and install it on an iPhone recovered during the investigation. In the wrong hands, this software — which does not exist today — would have the potential to unlock any iPhone in someone’s physical possession.”

Cook dismisses the government’s suggestion that this would be a once off situation, instead warning that the technique could be used as “the equivalent of a master key, capable of opening hundreds of millions of locks”.

“No reasonable person would find that acceptable.”

The iPhone 5C that San Bernardino shooter Farook used has an auto-erase function which destroys all of its encrypted data if it detects a hacker.

The FBI hopes to be able to automatically generate innumerable possible passwords until the correct one is found, with Apple’s assistance.

"Apple has the exclusive technical means which would assist the government in completing its search, but has declined to provide that assistance voluntarily," the US Attorney's Office in Los Angeles told reporters Tuesday.

Investigators already obtained Farook's iCloud data through back-up versions, but the most recent of the back-ups is only as recent as October, meaning Farook "may have disabled the feature to hide evidence", prosecutors said.

For months the debate between tech companies and national security officials has grown to a fever pitch. Ideally, the government would like a backdoor for all encrypted devices, so that a court order automatically grants them access, but encryption experts say that would create more problems than it would solve, leaving all encryption and major parts of the internet open to hackers or at the very least, giving foreign technology firms an upper hand in providing security to customers.

National Security Agency whistleblower Edward Snowden has been weighing in on the iPhone controversy on Twitter, pointing out how easily the changes sought by the FBI could make it to break into an iPhone: