Public keys and asymmetrical encryption to exchange a symmetrical encryption key. When I want to send you a message, my devices generates 2 encryption keys. A (private) and B (public). Messages (plaintext) encrypted with one key (ciphertext) can only be decrypted by the other key. You cannot decrypt using the same key it was encrypted with.
To simplify it we will use a substitution cipher. The most basic of all ciphers/encryption.
The “A” key will increment each letter by +1. So D -> E, E -> F, and so on. The “B” key will increment by -1, so P -> O.
A Key + BOOBS = CPPCT
If we try to decrypt using the A Key
A Key + CPPCT = DQQDU = wrong
Now the B Key
B Key + CPPCT = BOOBS = correct
It’s important here to point out that modern encryption algorithms are vastly more complex, and as of now the most complex of them have yet to be broken. The keys generated are complex enough to avoid collision, or when someone else’s key pair might accurately decrypt your message.
Ok, now that we have our keys, we always keep one secret and only known to us, the private key. Use encode the message we want to send using our Private key(A). Along with the encrypted ciphertext we will send our Public Key (B) in clear text. Our friend gets the encrypted message CPPCT and our B Key. They decrypt the message, B key + CPPCT = BOOBS. It makes them laugh. They want to send us back LOL. They use their B Key and at the end of the message they include their Public B key, but this time they encrypt their B key with our B Key.
Since my Private Key A is the only thing in existence that can decrypt messages encrypted with my public B key, the sender knows I’m the only person that can read the message they sent. I use my Private A key, decrypt their B key they sent, and use that to decrypt their message “LOL”.
Now that we have exchanged keys, and have a secure method to exchange messages, anytime I want to send my friend a message, I encrypt it with their Public B key, which ensures only they can decrypt it with their private A key. The problem is asymmetrical encryption like this is slow. Using the secure exchange we setup we mutually agree to start using a symmetrical encryption method and generate a key to use (Key C). Symmetrical encryption uses only one key for both encryption and decryption, and is much faster than asymmetrical. Going forward we can both just use Key C to encrypt our communications.
What’s cool is that even if someone got an exact copy of that first message, it doesn’t matter. When my friend returns the message, which includes their public key, the message is encrypted with my public key. Using my Private key is the only way to decrypt the public key they generated and sent for this session.
Latest Answers