title: Getting exception of Invalid length in decryption from AES Algorithm
body: <p>I am getting exception of invalid length in time of decryption in AES algorithm in C#, while it's working fine in android code.</p>
  
  <p>Android Code:</p>
  
  <pre><code>     public byte[] decryp_decompress(byte[] raw, byte[] encrypted)
                    throws Exception {
             SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
             Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
             cipher.init(Cipher.DECRYPT_MODE, skeySpec);
             byte[] decrypted = cipher.doFinal(encrypted);
             GZip gzip = new GZip();
             byte[] decompressData = gzip.decompresses(decrypted);
  
             return decompressData;
      }
  </code></pre>
  
  <p>C# Code:</p>
  
  <pre><code>    public byte[] Decrypt(byte[] encryptedData, RijndaelManaged rijndaelManaged)
      {
          try
          {
              return rijndaelManaged.CreateDecryptor().TransformFinalBlock(encryptedData, 0, encryptedData.Length);
          }
          catch
          {
              throw;
          }
      }
  </code></pre>
  
  <p>And </p>
  
  <pre><code>    public RijndaelManaged GetRijndaelManaged()
      {
          try
          {
              byte[] AESKey = new byte[] { **** };
              var keyBytes = new byte[16];
              var secretKeyBytes = AESKey;
              Array.Copy(secretKeyBytes, keyBytes, Math.Min(keyBytes.Length, secretKeyBytes.Length));
              return new RijndaelManaged
              {
                  Mode = CipherMode.ECB,
                  Padding = PaddingMode.None,
                  KeySize = 128,
                  BlockSize = 128,
                  Key = keyBytes
              };
          }
          catch
          {
              throw;
          }
      }
  </code></pre>
  
  <p>Getting exception in time of decryption of invalid length.</p>
  
  <p>What could the issue be?</p>
  
  <p>Edit:</p>
  
  <p>I have made changes for decryption:</p>
  
  <pre><code>  KeyParameter par = new KeyParameter(AESKey);
    // SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
     IBufferedCipher cipher = CipherUtilities.GetCipher("AES/ECB/NoPadding");
      cipher.Init(true, par);
          // Gives me "pad block corrupted" error
          byte[] output = new byte[(encryptedData.Length)];
          int len = cipher.ProcessBytes(encryptedData, 0,    encryptedData.Length, output, 0);
          cipher.DoFinal(output, encryptedData.Length);
          // byte[] output = cipher.DoFinal(encryptedData);
          return output;
  </code></pre>
  
  <p>but getting exception of  data not block size aligned.</p>
  
  <p>My data saved in little endian format . so any please help me where i need to update the code.</p>