According to http://en.wikipedia.org/wiki/RSA_%28algorithm%29#Key_generation the key length is the number of bits in n. So how can a message of many megabytes (millions of bits) be modded by a 1024 bit n? I never hear of a block mode for RSA, for instance.

  • $\begingroup$ The title of your question asks about encoding text as a number. Text in a computer is already encoded as a series of numbers we call bytes. The encoding varies, but common encodings are ASCII, Unicode UTF-8, etc. We simply place the bytes next to each other in an array, and they can be treated as a big number, just like placing digits 1, 2, and 3 next to each other makes a bigger number of 123. We don't care if the big number has a numerical meaning, because we're just going to re-encode it back to ASCII after decrypting anyway. $\endgroup$ – John Deters Jun 5 '13 at 0:03
  • $\begingroup$ @Gilles Agreed. It is a duplicate. That's really what I meant to ask, but I phrased it differently. I couldn't find it when I searched. Do I delete my question? I'm not sure the etiquette here. $\endgroup$ – Roman Zabicki Jun 9 '13 at 18:50
  • $\begingroup$ @RomanZabicki No, don't delete your question, it's useful for other people who will phrase their question like you rather than like the other asker. Once a few more people vote to close, your question will look like this. $\endgroup$ – Gilles 'SO- stop being evil' Jun 9 '13 at 18:57

You never use RSA to encrypt large binary objects, since it's to expensive to do many calculations.

Instead, RSA is used in a key exchange or key transport protocol to send a key for a symmetric-key algorithm, such as AES (with a cipher chaining mode, such as CBC), which is then used to encrypt huge messages.

Also note that textbook RSA isn't secure. Some differences between textbook RSA and deployed RSA are mentioned there: https://crypto.stackexchange.com/a/1449/4874


Not the answer you're looking for? Browse other questions tagged or ask your own question.