Public key cryptography (also known as public key encryption or asymmetric cryptography) is a method of encrypting data with two different keys. One of the keys is the public key and is available for anyone to use. The other key is known as the private key and is private for each individual. In this system, the sender (anyone) can encrypt a message using the receiver’s public key, but that encrypted message can only be decrypted with the receiver’s private key. This ensures that only the receiver will be able to read the message.
Consider the example below that describes how public key cryptography works and how it differs from symmetric cryptography:
Imagine a locked box containing letters that Alice and Bob use to communicate back and forth. The lock has only two states: locked and unlocked. Both Alice and Bob have a copy of the one and only key that can lock and unlock the box. So, Bob can add his letter, lock the box with his key, and send it to Alice. Then, Alice will simply unlock the box with her copy of the key and do the same. This is essentially the logic behind symmetric cryptography – one secret key is used for both encrypting and decrypting, and both sides of a conversation use the same key.
Now, consider a new type of lock that has three states:
This is shown in the diagram below:
Instead of one key, two keys go with this lock:
This means that if the box is locked and the key is turned to position A, only key No. 2 can unlock it by turning right to position B (unlocked). If the box is locked in position C, only key No. 1 can unlock it by turning the lock left to position B.
In other words, either key can lock the box, but once it is locked, only the other key can unlock it. This is essentially the idea behind public key, or asymmetric cryptography.
There are several public key cryptography algorithms including the Diffie–Hellman key exchange and the RSA Algorithm.
Free Resources