Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I read in Wikipedia about the Diffie–Hellman key exchange. But i can't imagine numbers which are hard to guess.

Can anybody give me a real-world example for $p$, $g$ and the two random secrets?

share|cite|improve this question
up vote 1 down vote accepted

I am Bob and I am communicating with Alice. You are Eve, the eavesdropper and you see the following information being passed between us.

$p$ = a 396 digit prime 315791951375393537137595555337555955191395351995195751755791151795317131135377351919777977373317997317733397199751739199735799971153399111973979977771537137371797357935195531355957399953977139577337393111951779135151171355371173379337573915193973715113971779315731713793579595533511197399993313719939759551175175337795317333957313779755351991151933337157555517575773115995775199513553337335137111

$g$ = 5

$g^a \mod p$ = 27489633325073800398775665555817886420250962668110351939566023888497836125868152406573384812160988816636135839671600830972123154326698347543908237984222952075526254924036242003399678149299821208547691422947419851811974028751045560581548575054043995970503234125889791605774889110477621403114012112713190957314561511096280698589221374817602716179951101187316281123669357781523803509664317497207729

$g^b \mod p$ = 1871328666565825995546798366128332313007950715331716749713204590388482544710311757501721471367857473733174282285058381076423826262539615001751155796241435075482428300917592530410990583546909080238556317378367406354698458062808098314556896127603125072486660646729701592117222647853144199702370081278435240604316086143749700366105405028431580266698489313733272288229202699113269909480645581599706251

and now you tell me what is the secret that Alice and I share $g^{ab} \mod p$.

share|cite|improve this answer
thanks thats exactly what i've looked for.. i'll give it a try =) – wutzebaer Sep 8 '13 at 12:12
when using this algorhitm, is it a security problem if i use always the same p? or does it not matter? – wutzebaer Sep 8 '13 at 12:23
can you tell me how much digits "a" has? – wutzebaer Sep 8 '13 at 16:35
@wutzebaer Well you are supposed to use this exchange to establish a common key for a symmetric cipher like AES and then use AES for your actual communication. Symmetric ciphers are way faster than asymmetric ciphers. And then at the beginning of the next cipher I would use another prime p and have a new common key. As for $a$, nope I can't tell you how many digits does it have. That's part of the fun. – Fixed Point Sep 9 '13 at 5:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.