Public-key cryptography uses two keys: a public key that can encrypt messages but not decrypt them, and a private key that can decrypt messages but not encrypt them. RSA is a widely used public-key cryptosystem that relies on the difficulty of factoring large prime numbers. It works by having users generate a public/private key pair using prime numbers, then allows encryption with the public key and decryption with the private key. The security of RSA depends on the computational difficulty of factoring the modulus used or determining the private key by other means.