Diffie-Hellman Playground

The same exchange at every size: start with the primes from the worksheet, then watch what changes, and what does not, when p has 600 digits.

Public parameters Everyone, including Eve, sees p and g.

p  

The exchange Each side raises g to a secret exponent, publishes the result, then raises the other's result to the same secret.

Or type secrets below and press Enter.

Alice knows a

secret a
publishes A = ga mod p
computes K = Ba mod p
A ⟶
⟵ B

Bob knows b

secret b
publishes B = gb mod p
computes K = Ab mod p
Powers of g mod p, with A, B and K marked
How Alice computes Ba by repeated squaring

Eve She has p, g, A and B. To get K she needs a or b: a discrete logarithm.

Find a from A by trying every exponent

Eve computes g, g², g³, … until one of them equals A.