Modular Exponentiation

Performs modular exponentiation, as used in Diffie-Hellman and RSA.

Input: TextResult: Text

Text input

Tool options

Examples

using input field for base

Input

5

Expected answer

JSON
6
Base
(empty)
Modulus
7
Exponent
3
using input field for exponent

Input

4

Expected answer

JSON
5
Base
2
Modulus
11
Exponent
(empty)
base one

Input

Expected answer

JSON
1
Base
1
Modulus
1000
Exponent
999
basic example (2^10 mod 1000)

Input

Expected answer

JSON
24
Base
2
Modulus
1000
Exponent
10
crypto-sized numbers (RSA-2048 simulation)

Input

Expected answer

JSON
1
Base
12345678901234567890123456789012345678901234567890
Modulus
99999999999999999999999999999999999999999999999999
Exponent
0
exponent zero

Input

Expected answer

JSON
1
Base
999
Modulus
100
Exponent
0
Fermat's Little Theorem (a^(p-1) mod p = 1)

Input

Expected answer

JSON
1
Base
3
Modulus
11
Exponent
10
hexadecimal input

Input

Expected answer

JSON
256
Base
0x10
Modulus
1000
Exponent
0x2
large base and exponent

Input

Expected answer

JSON
560583526
Base
123456789
Modulus
1000000007
Exponent
65537
RSA-like example (small)

Input

Expected answer

JSON
561
Base
123
Modulus
1000
Exponent
456

Computes Base ^ Exponent mod Modulus. Input handling: If either Base or Exponent is left blank, its value is taken from the Input field.

Format reference: Modular Exponentiation background and specification

Parameters

ParameterDefault valueInput and choices
Base""Text
Modulus"1"Text
Exponent""Text

Related tools

Browse arithmetic / logic tools