How to prove that existence of one-way functions implies P!=NP?

Wikipedia:

The existence of such one-way function… would prove that the complexity classes P and NP are not equal.

How is this proved?