How can we encode and decode a number x in RSA? Recall m = pq and vw = 1 mod (p - 1)(q - 1).

Encoding in RSA

The number x is encoded into y where

y = xv mod m.

Decoding in RSA

The number x is regained from y by means of

x = yw mod m.


Indeed, decoding is the inverse of encoding, as follows from Fermat's little theorem:

y = xvw = xa(p - 1)(q - 1) + 1 = x mod m.

Schematically this looks like: