Diffie-Hellman Key Exchange
How do two people agree on a secret while a spy listens to everything they say? Diffie-Hellman — the breakthrough that made public-key cryptography possible.
Controls
Presets
Diffie-Hellman lets two strangers agree on a secret key while an eavesdropper hears everything. Both share public numbers g and p, each picks a private exponent, and they exchange g raised to it. Raising the other's public value to your own secret yields the same shared key — yet recovering it from the public traffic requires solving the discrete logarithm, which is infeasible.
Data Inspector
Governing equation
Runs locally in your browser — free forever. Scale to the cloud when reality gets heavy.
How it works
Both parties share public numbers, each keeps a private exponent, and they swap the generator raised to those secrets. Raising the other's public value to your own private exponent gives an identical shared key. An eavesdropper sees all the public values but would need to solve the discrete-logarithm problem to recover the key — computationally infeasible.
Ask the AI about this model
The math, the assumptions, real-world uses, or a code translation — explained for this exact simulation.