Skip to content
ENExplore Calculators

Discrete Logarithm Calculator

Work out discrete logarithm instantly with clear inputs, formula shown and shareable results.

About Discrete Logarithm Calculator

The discrete logarithm asks for the exponent x with gˣ ≡ h (mod p). No efficient classical algorithm is known for large p, and that hardness is precisely what secures Diffie-Hellman key exchange.

Formula

Discrete logarithm

find x such that gˣ ≡ h (mod p)

Worked example

With the default values below, Discrete Logarithm Calculator returns Exponent x with gˣ ≡ h of 4. Change any input above and every figure here is recalculated in your browser.

Inputs used

Base gminimum 2
3
Target value hminimum 1
13
Modulus pminimum 2
17

Results

Exponent x with gˣ ≡ h
4
gˣ mod p (should equal h)
13
Multiplicative order of g
16
Size of the search space p − 1
16

Step by step

  1. 1Values used
  2. 2Discrete logarithm
  3. 3Exponent x with gˣ ≡ h= 4
  4. 4gˣ mod p (should equal h)= 13
  5. 5Multiplicative order of g= 16
  6. 6Size of the search space p − 1= 16

Assumptions and limits

  • The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

Solve 3ˣ ≡ 13 (mod 17).

x = 4, since 3⁴ = 81 = 4 × 17 + 13.

Why is it considered hard?

The best general algorithms take time roughly exponential in the digit count, so a 2048-bit modulus is out of reach — though Shor's quantum algorithm would break it.

Discrete Logarithm Calculator | Calcrivo