Diffie-Hellman Key Exchange Simulator
Visualize how two parties derive a shared secret.
What is DH Simulator?
An educational simulator that walks through the Diffie-Hellman key exchange step by step, showing how Alice and Bob derive a shared secret.
How it works
Public parameters (prime, generator, private keys) are combined to compute each party's public value and the shared secret, with every step shown.
- Enter your input. Type or paste your input into the field above — the tool responds instantly.
- Review the result. Output updates live as you type. Everything runs entirely in your browser.
- Copy or download. Use the Copy button to grab the result, or Download to save it as a file.
Examples
Shared secret over a public channel
Simulate a Diffie–Hellman exchange — Alice and Bob combine their private values with each other's public values to derive the same secret.
Common mistakes
No authentication
Plain DH is vulnerable to man-in-the-middle attacks — real systems authenticate the exchange (e.g., TLS).
Frequently asked questions
What makes DH work?
The discrete-logarithm problem: given a public base and two public values, computing the shared secret without the private values is infeasible.
Is this safe to use directly?
The simulation is for learning — production key exchange should use a vetted protocol like TLS or ECDH.