I am creating a C # Winforms application that sends data to a server via HTTPS.
The entry mechanism should be like this:
- I send the username to the server, it responds with the rsa-module and rsa-exponent 
- I encrypt the password using this data and send the username + password to the server for authentication 
I tried the RSACryptoServiceProvider class, but I can not find samples or anything that said , how can we do encryption using this module and exponent? .
I think that without specifying any values, it executes the default encryption settings.
So, if someone has done this before, can they give me some hints? thanks
UPDATE : as proposed by Mr. Karsten Koenig. I tried to do this using RSAParameters and RSA.ImportParameters , but it returns a "BAD DATA" error with a cryptographic exception. My code is below.
I also tried RSA.FromXmlString(mykey) ; (where mykey contains an xml string with module and exp), but I also get a "BAD DATA" error with a cryptographic exception ... any idea is anyone? or if its some bug at Microsoft, can anyone suggest some other decent library to make this easy?
 RSAParameters rsaparam = new RSAParameters(); rsaparam.Modulus = modbytes; rsaparam.Exponent = expbytes; RSACryptoServiceProvider RSA = new RSACryptoServiceProvider() ; RSA.ImportParameters(rsaparam); byte[] encryptedData = RSA.Encrypt(dataToEncrypt, false) 
source share