# How to encrypt the number one using RSA?

for example: if we have public key : (5,221) and private key : (77,221) and we want to encrypt 1:

c(m) = (m)^p mod n
c(m)=(1)^77 mod 21 =1


so how to deal with that? is there some work around ?

• How to deal with what? The encryption of 1 is 1, so what? – fkraiem Aug 21 '17 at 1:29

## 1 Answer

The algorithm you quote is usually called textbook RSA and is not used in practice for numerous security reasons (the problem you pointed out, is just one of them).

In practice, you have to pad (or armor) your message. This should be done using the RSA-OAEP (also called PKCS#1 v2.0) scheme. It transforms your message (1) into a pseudorandom block (not 1) which is then processed by the RSA encryption.

• could you include example with your answer please ? – Mr.lock Aug 20 '17 at 16:58
• @Mr.lock OAEP uses cryptographic hashes and requires realistic key sizes, so there is little point in posting an example. – CodesInChaos Aug 20 '17 at 18:35
• You can take a look at some test vectors, that the message is a single byte with value 1 won't make much of a difference within the calculations that need to be performed – Maarten Bodewes Aug 20 '17 at 21:04
• You could post a practical example of RSA-KEM! That's much simpler than the rigmarole of RSAES-OAEP. – Squeamish Ossifrage Aug 21 '17 at 1:56
• It’s not random if it’s deterministic and reversible – Cole Johnson Aug 21 '17 at 7:04