Credit: CC0 Public Domain

President Donald Trump weighed in Wednesday on Apple's dispute with the US government over giving law enforcement access to encrypted iPhones, saying the company "has to help."

"I understand both sides of the argument," Trump told CNBC in an interview from the Davos economic forum.

But "we should start finding some of the bad people out there that we can do with Apple. I think it's very important," he said.

Trump said Apple "have the keys to so many criminals and criminal minds."

Apple and the US government are at loggerheads for the second time in four years over unlocking iPhones connected to a , reviving debate over law enforcement access to encrypted devices.

Attorney General Bill Barr said Monday that Apple failed to provide "substantive assistance" in unlocking two iPhones in the investigation into the December shooting deaths of three US sailors at a Florida naval station, which he called an "act of terrorism."

"You're dealing with drug lords and you're dealing with terrorists, and if you're dealing with murderers, I don't care," said Trump.

"We have to find out what's going on," he added.