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
- Enter the prime modulus (p) and generator (g) values.
- Set each party private key value.
- Review the public keys and shared secret computed by the DH protocol.
- Verify the shared secret matches on both sides to confirm the protocol works correctly.
- 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 Key | Bob's Public Key | Shared Secret |
|---|---|---|---|
| 12 | 9 | 13 | 6 |
| 36 | 6 | 18 | 8 |
| 66 | 16 | 21 | 18 |
| 90 | 18 | 9 | 3 |
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 pWorked example, using the default values
- Identify Input Parameters4 parametersPrime Modulus (p) = 23, Generator (g) = 5, Alice's Private Key (a) = 6, Bob's Private Key (b) = 15 = 4 input(s) provided
- Calculate Alice's Public KeyAlice's Public Key8 = 8
- Calculate Bob's Public KeyBob's Public Key19 = 19
- Calculate Shared SecretShared Secret2 = 2
- Calculate Discrete Log ComplexityDiscrete Log Complexity4.8 = 4.8
Engine last updated . Checked against 3 independently-derived tests — how we verify calculators.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Cryptography & Security
RSA Key Strength Calculator
Calculate RSA key strength, equivalent symmetric key length, brute force time, and security margins.
Cryptography & SecurityElliptic Curve Cryptography Calculator
Calculate ECC key strength, equivalent RSA key length, security level, and cryptographic parameters.
Cryptography & SecurityEncryption Key Space Calculator
Calculate encryption key space size, brute force time, and security level for cryptographic algorithms.
More in Technology & Computing.