title: RSA Decryption Issue C#
body: <p>RSA Decryption Issue</p>
  
  <p>I am having problems with a C# RSA program. It is not decrypting properly. When I assign <code>d =(e^-1)%phiN</code>, and then apply d to my ciphertext it comes up with ridiculous decimal answers. It should come up with a whole number. I think it is a problem with my math. Do you have any advice? 
  If you need details or the rest of the code, please ask.
  Also, is there a padding scheme I could use to make this code better? Right now this code is vulnerable to frequency analysis.</p>
  
  <pre><code>protected void decryptRSA(object sender, EventArgs ev)
  
  {
          double p = (double)Convert.ToInt64(P.Text);//I use 123 for testing
          double q = (double)Convert.ToInt64(Q.Text);//127
          double e = (double)Convert.ToInt64(E.Text);//133
          double phiN = (p-1)*(q-1);
          double n = p*q;
          double d = Math.Pow(e, -1D);
          d = d%phiN;
  
          string cipherStr = outputBuffer.Text;
          double[] cipherTextDouble = new double[100];
          string[]plainText = new string[cipherTextDouble.Length];
  
          cipherTextDouble = parser(cipherStr, 'D');
       for(int slot = 0; slot&lt;cipherTextDouble.Length; slot++)
          {
      cipherTextDouble[slot] = (double)(Math.Pow((double)cipherTextDouble[slot],(double)d)%n);
          }
          for(int slot = 0; slot&lt;cipherTextDouble.Length; slot++)
          {
              inputBuffer.Text += Convert.ToChar(cipherTextDouble[slot]) + ' ';//the spot were it dies
  //it doesn't like to convert from a decimal like 1.75 to a char. Of course I should never get a decimal like 1.75, which is the problem
          }
      }
  </code></pre>