title: "Bad Data" CryptographicException
body: <p>First, I have only written the code below for academic purposes. The reason I say this is because I am not putting this in a production environment, and therefor am "bypassing" some of the overhead that I would need to do if I was, I simply need to be able to encrypt/decrypt a string using the code below. I was able to do it a few time, but for some reason, I started receiving "CryptographicException Bad Data" and am not sure what might be causing the problem.</p>
  
  <pre><code>   private string RSAEncrypt(string value)
      {
          byte[] encryptedData = Encoding.Unicode.GetBytes(value);
  
          CspParameters cspParams = new CspParameters();
          cspParams.KeyContainerName = _rsaContainerName;
          using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048,cspParams))
          {
              encryptedData = RSA.Encrypt(encryptedData, false);
              return Convert.ToBase64String(encryptedData);
  
          }
  
      }
  
  
  
      private string RSADecrypt(string value)
      {
  
          byte[] encryptedData = Encoding.Unicode.GetBytes(value);
  
          CspParameters cspParams = new CspParameters();
          cspParams.KeyContainerName = _rsaContainerName;
          using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048,cspParams))
          { 
              encryptedData = RSA.Decrypt(encryptedData,false);
              return Convert.ToBase64String(encryptedData);
  
          }
      }
  </code></pre>
  
  <p>It is only throwing this exception on the RSADecrypt call. </p>
  
  <p>Any ideas? I read somewhere it might have to do with the expected size of encryptedData that is passed into RSA.Decrypt.</p>
  
  <p>Thanks
          }</p>