# RSA - encrypted plaintext results in the same ciphertext value

Just started learning about RSA cryptography so forgive me if I made any mistakes or misunderstandings.

M = 20 be the message that i want to encrypt

N = 5*7 , p = 5 and q = 7

φ(N) = (5-1)(7-1) = 24

Let e = 5 as it is a coprime of 24

To encrypt the message, E = M^e mod(N)

This works out to E = 20^5mod35 , which equates to 20 as well

I have tried other values of e but the ciphertext is always 20. Is there anything wrong with having the plaintext and ciphertext being the same?

• What you are learning with is called "textbook rsa" and with very small numbers, which is not cryptographic rsa, which uses VERY large numbers and additional functions to make 2 identical plaintexts produce different ciphertexts, see crypto.stackexchange.com/questions/1448/… Jan 4 at 2:44
• Jan 4 at 6:22
• RSA goes with messages M<N Jan 5 at 15:00

Is there anything wrong with having the plaintext and ciphertext being the same?

What you're seeing is an artifact of your choice of plaintext (which is made rather more likely because of your tiny modulus).

We have $$20^e \equiv 20 \pmod{35}$$ for any odd $$e$$; this happens because:

$$20 \equiv 0 \pmod 5$$, and so $$20^e \equiv 20 \pmod 5$$ always

$$20 \equiv -1 \pmod 7$$, and so $$20^e \equiv 20 \pmod 7$$ for any odd $$e$$.

The above two (along with the similar $$m \equiv 1 \pmod p$$) are simultaneously true for both prime factors for 9 different ciphertexts; it's just that when you start with 35 possible ciphertexts, picking one of the unlikely 9 isn't that much of a coincidence.

For 35, the 9 values of $$m$$ for which $$m^e=m$$ are true are: 0, 1, 6, 14, 15, 20, 21, 29, 34.

Tiny modulii show other artifacts as well (such as the public and private exponents being the same often); that can be misleading if you are attempting to learn RSA by examining their behavior.