Explain how public key cryptography works, including the RSA algorithm and why it is considered secure.