Grokking Algorithms


Diffie-Hellman key exchange



Yüklə 348,95 Kb.
Pdf görüntüsü
səhifə108/122
tarix05.12.2023
ölçüsü348,95 Kb.
#173611
1   ...   104   105   106   107   108   109   110   111   ...   122
grokking-algorithms-illustrated-programmers-curious

Diffie-Hellman key exchange
The 
Diffie-Hellman algorithm
deserves a mention here, because it solves 
an age-old problem in an elegant way. How do you encrypt a message 
so it can only be read by the person you sent the message to? 
The easiest way is to come up with a cipher, like a = 1, b = 2, and so on. 
Then if I send you the message “4,15,7”, you can translate it to “d,o,g”. 
But for this to work, we both have to agree on the cipher. We can’t agree 
over email, because someone might hack into your email, figure out 
the cipher, and decode our messages. Heck, even if we meet in person, 
someone might guess the cipher—it’s not complicated. So we should 
change it every day. But then we have to meet in person to change it 
every day! 
Even if we did manage to change it every day, a simple cipher like this 
is easy to crack with a brute-force attack. Suppose I see the message 
“9,6,13,13,16 24,16,19,13,5”. I’ll guess that this uses a = 1, b = 2, and
so on.
That’s gibberish. Let’s try a = 2, b = 3, and so on.


218
Chapter 11
 
 
I
 
 
Where to go next
That worked! A simple cipher like this is easy to break. The Germans 
used a much more complicated cipher in WWII, but it was still cracked. 
Diffie-Hellman solves both problems: 
• Both parties don’t need to know the cipher. So we don’t have to meet 
and agree to what the cipher should be. 
• The encrypted messages are 
extremely
hard to decode.
Diffie-Hellman has two keys: a public key and a private key. The public 
key is exactly that: public. You can post it on your website, email it 
to friends, or do anything you want with it. You don’t have to hide it. 
When someone wants to send you a message, they encrypt it using 
the public key. An encrypted message can only be decrypted using the 
private key. As long as you’re the only person with the private key, only 
you will be able to decrypt this message!
The Diffie-Hellman algorithm is still used in practice, along with its 
successor, RSA. If you’re interested in cryptography, Diffie-Hellman is a 
good place to start: it’s elegant and not too hard to follow.

Yüklə 348,95 Kb.

Dostları ilə paylaş:
1   ...   104   105   106   107   108   109   110   111   ...   122




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin