title: C# Rijndael CryptographicException "Length of the data to encrypt is invalid."
body: <p>I am trying to encrypt and decrypt a file with the rijndael algorythm, but i have been getting the error "Length of the data to encrypt is invalid.". I am able to encrypt the file, but i can't decrypt it. This is my decryption function;</p>
  
  <pre><code>    public static byte[] Decrypt(byte[] toEncryptArray)
      {
          byte[] keyArray = UTF8Encoding.UTF8.GetBytes("-key-");
          RijndaelManaged rDel = new RijndaelManaged();
          rDel.Key = keyArray;
          rDel.Padding = PaddingMode.PKCS7;
          ICryptoTransform cTransform = rDel.CreateDecryptor();
          return cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
      }
  </code></pre>
  
  <p>I honestly have no idea what i am doing wrong, as i can encrypt it perfectly fine. The file i am trying to decrypt is 11 kb.</p>