system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How is the HTTPS handshake kept secret?

I believe I understand how HTTPS works: messages are sent from one computer to the other encrypted, so that when intercepted it's not readable. UNLESS you know the secret encryption method (I think they are called "keys").

So I envision two people saying: "Hey, let's talk in secret by replacing every letter in the alphabet with its corresponding number times three minus five"
"uh, brilliant, nobody will ever figure this out!"

Except of course if somebody listened to the first bit of their conversation.

From what I have learned this initial exchanging of encryption methods is called the handshake.

Seems like once the handshake is intercepted, the whole encryption breaks down. 

So how is the handshake kept secret?
gpt
Here's a reasonable analogy:

Imagine that you want to exchange a secret message with someone, who lives on the other side of the country, using the public mail service.

The only tools you both have at your disposal are an infinite supply of boxes (made of some magical unbreakable material), an infinite supply of unpickable self-locking padlocks which can be used to lock the boxes, and one key, which can be used to unlock any of those padlocks. For each of you the key you have will only unlock your padlocks, nobody else's.

So you take one of the boxes, put one of your padlocks in it, you *don't* lock the box, and you send that to your friend.

When your friend receives it, he puts the instructions about what secret code you'll use into the box along with one of his padlocks, and then locks the box *with your padlock*. He can no longer open the box because it's locked with your padlock, and importantly nobody else can open the box even if they intercept it while it's in the postal system.

When you finally get the box, you have the only key in the entire world that is able to open the box. You open it, take out his padlock, write an acknowledgement that you've received the message safely and securely, and put that into another box that you lock with *his* padlock. Now *you* can't re-open the box (nor can anyone else) -- only when your friend receives it can it be opened.

And that's the basis of public-private key encryption key exchange. You encrypt (lock) the message using the *other person's public key* which means the other person is the only one who can unlock it, because they have the private key. 

-----

(Small print -- the above isn't a perfect analogy, in particular at the initial stage the first padlock you send to your friend is vulnerable to being intercepted en route and replaced with a different padlock belonging to someone who wishes to intercept & read all the communication between the pair of you: this technique is known as a "man in the middle" attack. To get round this in the real world the initial communication is signed by a certificate issued by a trusted authority, which guarantees to the recipient that the message they receive is the same as the one that was sent).