Skip to main content
Calcimator

Diffie-Hellman Key Exchange Calculator

Calculate Diffie-Hellman key exchange parameters, shared secret, and security analysis.

Inputs

Results

Alice's Public Key

8

Bob's Public Key

19

Shared Secret

2

Security Level

4.5 bits

Discrete Log Complexity4.8
How to Use This Calculator
  1. Enter the prime modulus (p) and generator (g) values.
  2. Set each party private key value.
  3. Review the public keys and shared secret computed by the DH protocol.
  4. Verify the shared secret matches on both sides to confirm the protocol works correctly.
  5. Use group sizes of at least 2048 bits in production -- 768 and 1024-bit groups are deprecated.

How the result changes with Generator (g)

Generator (g)Alice's Public KeyBob's Public KeyShared Secret
129136
366188
66162118
901893

What each input means

Prime Modulus (p)
Large prime number
Generator (g)
Primitive root modulo p
Alice's Private Key (a)
Alice's secret private key
Bob's Private Key (b)
Bob's secret private key

How this is calculated

Formula

Shared Secret = (g^a)^b mod p = (g^b)^a mod p

Worked example, using the default values

  1. Identify Input Parameters
    4 parameters
    Prime Modulus (p) = 23, Generator (g) = 5, Alice's Private Key (a) = 6, Bob's Private Key (b) = 15 = 4 input(s) provided
  2. Calculate Alice's Public Key
    Alice's Public Key
    8 = 8
  3. Calculate Bob's Public Key
    Bob's Public Key
    19 = 19
  4. Calculate Shared Secret
    Shared Secret
    2 = 2
  5. Calculate Discrete Log Complexity
    Discrete Log Complexity
    4.8 = 4.8

Engine last updated . Checked against 3 independently-derived tests how we verify calculators.

The questions that sit next to this one — chosen by subject, including calculators filed under a different category.

More in Technology & Computing.