Diffie-Hellman Key Calculator

Enter the public parameters and both private keys to derive the shared secret.

How to use

  1. Enter your values in the fields above.
  2. Press Calculate to see your result instantly.
  3. Use the Share button to copy a link to your result.

About this calculator

The Diffie-Hellman key exchange lets two parties agree on a shared secret over a public channel without ever transmitting the secret itself. Both sides agree on a public prime modulus p and generator g; each picks a private key (a and b) and computes a public key — A = g^a mod p and B = g^b mod p — which they exchange openly. Each side then raises the other's public key to their own private key: the shared secret is s = B^a mod p = A^b mod p = g^(ab) mod p, arriving at the same number without either private key ever crossing the wire.

Security rests on the discrete logarithm problem — computing a from g, p and A = g^a mod p is computationally infeasible for a large enough prime p, even though computing A from a is easy. Computer science students, security engineers, and protocol implementers use small-number examples like this to verify by hand how TLS, SSH, and other protocols establish a shared session key before any application data is sent.

Was this helpful?

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators