Cryptography & Security
Intermediate

Modular Exponentiation

Core operation of RSA encryption — raise a message to a power, modulo n.

Formula

c=me mod nc = m^e \bmod n

Variables

cCiphertext
mMessage
ePublic exponent
nModulus

Example

m=4, e=3, n=33: c = 64 mod 33 = 31

How it works

Modular exponentiation means you take a message value, raise it to a chosen power, and then keep only the remainder after division by a modulus. In RSA, this is useful because it transforms the message in a way that is easy to compute with the public key, but much harder to reverse without the private key. The modulus keeps the numbers bounded, so the result always stays within a fixed range from 0 to n−1.

When to use it

Use this in public-key cryptography, especially RSA encryption and key-based protocols. It also appears in any problem involving powers under a modulus, such as fast modular arithmetic in number theory or computer security.

Worked example, step by step

Given m = 7, e = 4, n = 15 Step 1: Raise the message to the exponent: 7^4 = 2401 Step 2: Divide by the modulus and find the remainder: 2401 mod 15 Step 3: 15 × 160 = 2400, so the remainder is 1 Final answer: c = 1

Common mistakes to avoid

  • Forgetting to take the remainder after exponentiation, not at the end
  • Confusing the public exponent e with the modulus n
  • Using ordinary division instead of modular reduction

Did You Know?

Fast exponentiation lets computers raise huge numbers to huge powers in milliseconds — the engine of public-key crypto.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026