About this interactive
Public key cryptography solves a real problem: two parties who want to communicate securely but have never met, like your browser and a website you have never visited, have no pre-shared key. The lesson walked through the two most popular answers, Diffie-Hellman and RSA, named after the people who created them.
Diffie-Hellman is a key exchange. Each side has a private key and they agree on some shared values in the open. Each side combines its private key with the shared values to make a public key, and they swap public keys. Each side then combines the other's public key with its own private key, and the math makes both arrive at the same result. That is two private keys, two public keys and a shared value, and nothing was ever encrypted along the way. The result is a shared key that can then be used for encryption.
RSA uses one key pair: a public key anyone can have and a private key nobody else should. Whatever one key encrypts, only the other can decrypt. Encrypt a message with a server's public key and only that server can read it. If the server encrypts with its private key and you can decrypt with its public key, you know the message came from that server. That is why RSA can do encryption, identity checks, digital signatures and non-repudiation, not just key exchange.
Both are asymmetric, both have keys that are safe to make public, both turn up inside protocols such as TLS, SSH and IPsec, and both are slow compared with symmetric encryption. That last point is why they are usually used just to get two sides to a shared key, so a symmetric cipher can carry the bulk of the data.
About TechKnowSurge
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →