title: Not enough storage is available to process this command In RSA Encryption
body: <p>In RSA Encryption With RSACryptoServiceProvider USING ASP.NET C#
  , I Got This Error Why?
  What is Wrong in My Code?</p>
  
  <pre><code> [WebMethod]
      public string newDcrypt(string text)
      {
          UnicodeEncoding encoder = new UnicodeEncoding();
          string publickey = HttpContext.Current.Server.MapPath("Keys/publickey.pem");
          string privatekey = HttpContext.Current.Server.MapPath("Keys/privatekey.pem");
          RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
          privatekey = RSA.ToXmlString(true);
          byte[] datatodecrypt = Convert.FromBase64String(text);
          RSA.FromXmlString(privatekey);
          byte[] decryptdata = RSA.Decrypt(datatodecrypt, false);
          return Encoding.UTF8.GetString(decryptdata); 
      }
  </code></pre>
  
  <p>Error On This Line Of Code....</p>
  
  <pre><code>var decryptdata = RSA.Decrypt(datatodecrypt, false)
  </code></pre>
  
  <p>Encryption Is Fine Here Is Encryption Code....</p>
  
  <pre><code>  [WebMethod]
      public string NewEncrypt(string text)
      {
          UnicodeEncoding encoder = new UnicodeEncoding();
          string publickey = HttpContext.Current.Server.MapPath("Keys/publickey.pem");
          string privatekey = HttpContext.Current.Server.MapPath("Keys/privatekey.pem");
  
          RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
          publickey = RSA.ToXmlString(true);
          var datatoencrypt = encoder.GetBytes(text);
          var encryptedbytearray = RSA.Encrypt(datatoencrypt, false);
          RSA.FromXmlString(publickey);
          return Convert.ToBase64String(encryptedbytearray);
      }
  </code></pre>
  
  <hr>
  
  <p>Error:</p>
  
  <blockquote>
    <p>System.Security.Cryptography.CryptographicException: <strong>Not enough storage is available to process this command.</strong> 
       at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
       at System.Security.Cryptography.RSACryptoServiceProvider.DecryptKey(SafeKeyHandle pKeyContext, Byte[] pbEncryptedKey, Int32 cbEncryptedKey, Boolean fOAEP, ObjectHandleOnStack ohRetDecryptedKey)
       at System.Security.Cryptography.RSACryptoServiceProvider.Decrypt(Byte[] rgb, Boolean fOAEP)
       at DataEncryptDecrypt.Encryption.newDcrypt(String text) in e:\VS Projects\DataEncryptDecrypt\DataEncryptDecrypt\Encryption.asmx.cs:line 180</p>
  </blockquote>