Hi James,

James> I am wondering how I go about using rsa encryption for a message, then
James> base-64 encode the result. I don't want to encode before encrypting, btw.

James> Thank you for any help.

That's generally not the way to do it.  There are two main reasons for
not using RSA to encrypt a message:
    1. RSA (and asymmetric key algorithms in general) is *very* slow
    2. You are limited to a small message size.  For example,
       you need a very large RSA modulus (2000-3000 bits) to
       encrypt just 20 or 30 bytes of data. (Experts: don't flame me
       if I have the numbers wrong there.)

So, what you generally do is generate a random key for a symmetric
algorithm like AES (or RC4).  This key would be, say, 16 bytes long.

You encrypt your message (any length) with the AES algorithm -
very fast.

Using RSA you encrypt the AES key with the RSA public key.

You send the encrypted AES key and the encrypted message to the
receiver.

The receiver use his/her Private Key to decrypt the AES key, and then
uses that key to decrypt the actual message.

-- 
Russell Robinson (mailto:[EMAIL PROTECTED])
Author of Tectite, FormMail, FormMailEncoder


Reply via email to