🔐 encrypt.toolsALL TOOLS
DH · KEY EXCHANGE

Diffie-Hellman Key Exchange Simulator

Watch two parties agree on a shared secret over a public channel.

loading tool…
FIELD NOTES

About this tool

Diffie-Hellman (1976) was the breakthrough that made public-key cryptography possible: two people who have never met can agree on a shared secret while an eavesdropper watches every message. This simulator lets you set the public prime and generator, choose Alice's and Bob's private exponents, and see each public value and the resulting shared secret computed with exact BigInt arithmetic.

The math is g^a mod p and g^b mod p exchanged in the open; each side raises the other's public value to its own private exponent, both landing on g^(ab) mod p. Small demo parameters are used so the numbers are readable — real deployments use 2048-bit or larger primes, or elliptic-curve variants.

Like everything on encrypt.tools, this runs entirely in your browser — nothing you enter is transmitted or stored.

FREQUENTLY ASKED

Frequently asked questions about Diffie-Hellman Simulator

How can two people share a secret if an attacker sees everything?+

The security rests on the discrete logarithm problem: knowing g, p, and g^a mod p, it is computationally infeasible to recover the private exponent a for large primes. Alice and Bob each combine their own secret with the other's public value to reach the same result an eavesdropper cannot compute.

Why are the numbers in this tool so small?+

Small parameters keep the shared secret readable so you can follow the math. Real Diffie-Hellman uses primes of 2048 bits or more (or elliptic curves), where the numbers are hundreds of digits long.

Is Diffie-Hellman still used today?+

Yes — every HTTPS connection uses an ephemeral Diffie-Hellman exchange (usually the elliptic-curve variant, ECDHE) to establish forward-secret session keys. The principle you see here underlies TLS, SSH, and Signal.

RELATED INSTRUMENTS