Skip to content
Lab

RSA arithmetic

Factoring, modular inverse, exponentiation, integer root and text ↔ integer conversion.

RSA step by step

  1. 1. Factor nn = p × q
  2. 2. Euler's totientφ(n) = (p − 1)(q − 1)
  3. 3. Private exponentd = e⁻¹ mod φ(n)
  4. 4. Decryptm = c^d mod n
  5. 5. Integer → textm → hex → UTF-8
Integer e-th rootm = ⌊c^(1/e)⌋

Useful when e is small and the message short: if m^e < n, the modulo does nothing.

Text ↔ integer conversion