Discrete Log Solver

One group per line: g,h,p separated by comma or space, e.g. 5,8,23 means solve 5^x = 8 (mod 23)
Method:   Solutions:   Formula:
Order of g:   Max results:   Max m digits:   Separator:
Calculation Result Download CSV
No. Input (g,h,p) Method Solution x Verify Steps Note

Introduction to the tool and how to use it

Online discrete logarithm solver: find the exponent x in g^x ≡ h (mod p); enter one g,h,p triple per line to solve in batch.

Input format: one g,h,p triple per line, comma or space separated; for example 5,8,23 asks for 5^x ≡ 8 (mod 23).

Three algorithms: BSGS (baby-step giant-step, default; build a baby table with m = ⌈√n⌉ and collide giant steps), brute force (for small p, with an iteration cap), Pohlig–Hellman (when p-1 is smooth; factor n into prime powers and combine by CRT); choose compare all to see the step counts of all three at once.

Automatic checks: if g's order is not entered, it is detected automatically; the tool checks whether g and p are coprime and whether p is prime, and uses h^n ≡ 1 to decide whether h lies in the subgroup generated by g; if not, it clearly reports no solution within the given range.

Verification: every computed x is rechecked with g^x mod p = h, and the verification column shows pass or fail; optionally output all solutions x + k·n. All big-number arithmetic uses BigInt with fast exponentiation throughout, and p holds at most 120 digits.

How to use

  1. Paste each equation in g,h,p format, one per line.
  2. Choose the solving method, solution form, and other parameters.
  3. Click Run.
  4. Copy or export the solution x and the verification result.

Message board

All messages →
0/200

  • No one has spoken up yet — want to go first?