The Diffie-Hellman key exchange

Take on the roles of Alice and Bob! Exchange secret keys using the Diffie-Hellman key exchange method!! Use your keys to encrypt messages!!!

The Diffie-Hellman key exchange uses a large prime p and a primitive root g of this prime. These numbers are both public.

To start the key exchange process, Alice chooses a secret number a less than the large prime, and computes ga (mod p). Alice sends this answer, call it A, to Bob. Bob now chooses his own secret number b, and computes gb (mod p). Bob sends this answer, call it B, to Alice.

Finally, Alice computes Ba (mod p), and Bob computes Ab (mod p). They both get the same answer, but no-one else will know this secret answer, because only Alice knows a, and only Bob knows b. This secret answer is their private key, which they can use to encrypt messages.

[You may wonder why someone intercepting Alice and Bob's communication can't solve gx = A (mod p) to calculate Alice's secret number a. This is a hard problem, known as the discrete logarithm problem. That this is difficult is the strength of this method of key exchange.]

First you must be Alice. Choose a large prime from the list below (or one of your own choice) and a corresponding primitive root of that large prime. Then choose a secret number which is smaller than your large prime.

(mod )

Valid HTML5 Valid CSS!