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.
Now you must be Bob. You must use the same large prime and primitive root that Alice used [you should be able to copy and paste these from the form], but choose your own secret number.
Now Alice and Bob are ready to calculate their private key. Alice computes Ba (mod p), and Bob computes Ab (mod p). They both get the same answer, which no-one else can find out. This answer is their private key.
Be Alice again, and compute the private key [Alice's secret number goes in the middle box]:
Now Alice can encrypt a message. She can write the message as plain text. Each letter will be converted to a number, so A = 65, B = 66, etc to Z = 90. For simplicity here, Alice and Bob will only use capital letters, and will use no spaces or punctuation in their messages. The encryption will be done by adding successive digits of the private key to each letter's number, and converting this back to a letter (91 will revert to A, etc). If the message is longer than the private key, the digits will be used again from the start. Enter Alice's message in the box below [it will automatically be in uppercase; if you put in any spaces or other characters these will be ignored]:
You must once again be Bob, and crack Alice's code by converting letters to numbers, subtracting successive digits of the private key, and converting back to letters (any numbers below 65 cycle back to 90, e.g. 64 becomes 90).
Or, you can use this box to decrypt the message:
This page checks some of the numbers entered for errors. For example, it checks that the large prime entered is the same in each case. But not everything is checked. For example, the prime itself is not tested for primality by this page. So it is possible to compute incorrect messages or decryptions. Users may also want to know more about the meaning expressions such as ga (mod p). A search for 'modular arithmetic' will find clear explanations. The concept of a primitive root is harder to tackle; a web search will also find explanations.