RSA Private Exponent Calculator
Enter the public exponent e and the totient φ(n) to compute the private exponent d.
Result
How it is calculated
The tool finds d with e × d ≡ 1 (mod φ) using the extended Euclidean algorithm, which writes gcd(e, φ) = 1 as s·e + t·φ; the coefficient s, reduced into the range 0 to φ−1, is d. A second line, "check", multiplies e by d modulo φ and should always show 1. Both inputs must be whole numbers: e at least 1, φ at least 2, and neither above 253 (9007199254740992), because larger values cannot be held exactly. If e and φ share a common factor there is no inverse and the tool returns no result. An e larger than φ is accepted and behaves like e mod φ. This is a teaching tool for small numbers; it takes φ(n) as given and does not factor n or build a key.
Worked example
Take the textbook key with p = 61 and q = 53. Then φ = (61 − 1)(53 − 1) = 3120, and let e = 17. Euclid gives 3120 = 183·17 + 9, 17 = 1·9 + 8, 9 = 1·8 + 1. Working back, 1 = 2·3120 − 367·17, so e⁻¹ ≡ −367, which is 3120 − 367 = 2753. The tool shows d = 2,753. Check: 17 × 2753 = 46,801 = 15 × 3120 + 1, so the remainder is 1.
Common mistakes
- Entering n instead of φ(n). With p = 61 and q = 53, n is 3233 but φ is 3120; using n gives a d that does not decrypt anything.
- Choosing an e that shares a factor with φ. An even e never works because φ is even, and for φ = 3120 any e divisible by 2, 3, 5 or 13 returns no result.
- Calculating φ as p × q − 1 or (p − 1) + (q − 1). For two primes it is (p − 1)(q − 1), here 60 × 52.
- Copying the displayed d with its thousands separator (2,753 or, in some locales, 2.753) into code. Remove the separator before using the number.
- Expecting to enter real 2048-bit key values. Inputs above 253 are rejected, so use a library for production keys; this tool is for learning with small primes.
Sources
- Handbook of Applied Cryptography, Chapter 8: Public-Key Encryption (8.1 RSA key generation, 8.4 ElGamal) — Menezes, van Oorschot, Vanstone, CRC Press, 1996
- Handbook of Applied Cryptography, Chapter 2: Mathematical Background (Algorithm 2.107, extended Euclidean algorithm) — Menezes, van Oorschot, Vanstone, CRC Press, 1996
About this calculator
RSA key generation picks a public exponent e and computes the private exponent d as its modular inverse with respect to Euler's totient of the modulus: d ≡ e⁻¹ (mod φ(n)), meaning d is the unique value satisfying e·d ≡ 1 (mod φ(n)). It's found using the extended Euclidean algorithm rather than by simple division.
Cryptography students and instructors use this calculator to work through RSA key generation by hand and verify their arithmetic, and security engineers use it to sanity-check a manually constructed key pair or to understand exactly how e, φ(n) and d relate before implementing RSA in code.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Once you have d, test the pair with a round trip, which this tool does not perform. With n = 3233, e = 17 and d = 2753, the message 65 encrypts to 65 raised to 17 mod 3233, which is 2790, and 2790 raised to 2753 mod 3233 returns 65. If the message does not come back, recheck that you used phi, not n. Are you working through a textbook exercise or your own small example?