Diffie-Hellman key exchange
Compute a Diffie-Hellman shared secret from your private key and the other party's public value, entirely in your browser.
Diffie-Hellman key exchange
This calculator walks through one side of a Diffie-Hellman key exchange: given your private key and the public value you received from the other party, it derives your own public key and the shared secret both sides end up with. It's built for developers checking a handshake against a reference implementation, and for anyone learning how the protocol turns two private numbers into one shared one without either party ever sending it across the wire.
Pick a key size to choose the built-in prime (p) and generator (g = 2) the exchange runs over — 2048-bit is the safe default, 1024-bit is kept for working with legacy systems, and 512-bit is for following the arithmetic by hand, not for anything real. The public key format option reads the value you paste as decimal digits, hexadecimal or Base64, however it arrived; the output format controls how your own public key and the shared secret are rendered. An optional expected-value field checks the computed secret against one you already have, so you can confirm two implementations agree.
The tool rejects a private key that isn't a positive whole number and a public value of 0, 1 or p−1 — those degenerate values would produce a predictable shared secret no matter what private key is used, so a real implementation should reject them too. Note that classic Diffie-Hellman has no salt or iteration count; those belong to password-based key derivation, not to this exchange.
Everything runs locally in your browser using JavaScript's native BigInt arithmetic — your private key and the computed secret are never sent anywhere. Copy the result, download it as a .txt file, or send it back into the input to run another calculation.