title: error during decryption of pdf file in java
body: <p>I am using aes encryption to encrypt the pdf file it encrypts the file without any error but it is giving some error of parameters missing during the decryption of the pdf file.</p>
  <p>my code is for encryption and decryption is</p>
  <pre><code>import javax.crypto.Cipher;
  import javax.crypto.spec.IvParameterSpec;
  import javax.crypto.spec.SecretKeySpec;
  import java.io.*;
  
  public class Encrypt {
      public static void main(String[] args) {
          try{
  
  //            encryptWitEcb(&quot;src//d.pdf&quot; , &quot;src//d.enc.pdf&quot; , &quot;f1dda0fc3b96f6d0&quot;.getBytes());
              decryptWithEcb(&quot;src//d.enc.pdf&quot; , &quot;src//d.dec.pdf&quot; ,&quot;f1dda0fc3b96f6d0&quot;.getBytes());
          }catch (Exception e){
              e.printStackTrace();
          }
      }
  
      public static void encryptWitEcb(String filenamePlain, String filenameEnc, byte[] key) throws Exception{
          Cipher cipher = Cipher.getInstance(&quot;AES/GCM/NoPadding&quot;);
          SecretKeySpec secretKeySpec = new SecretKeySpec(key, &quot;AES&quot;);
          cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
          try (FileInputStream fis = new FileInputStream(filenamePlain);
               BufferedInputStream in = new BufferedInputStream(fis);
               FileOutputStream out = new FileOutputStream(filenameEnc);
               BufferedOutputStream bos = new BufferedOutputStream(out)) {
              byte[] ibuf = new byte[1024];
              int len;
              while ((len = in.read(ibuf)) != -1) {
                  byte[] obuf = cipher.update(ibuf, 0, len);
                  if (obuf != null)
                      bos.write(obuf);
              }
              byte[] obuf = cipher.doFinal();
              if (obuf != null)
                  bos.write(obuf);
          }
      }
  
      public static void decryptWithEcb(String filenameEnc, String filenameDec, byte[] key) throws Exception
              {
          try (FileInputStream in = new FileInputStream(filenameEnc);
               FileOutputStream out = new FileOutputStream(filenameDec)) {
              byte[] ibuf = new byte[1024];
              int len;
              Cipher cipher = Cipher.getInstance(&quot;AES/GCM/NoPadding&quot;);
              SecretKeySpec secretKeySpec = new SecretKeySpec(key, &quot;AES&quot;);
              cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
              while ((len = in.read(ibuf)) != -1) {
                  byte[] obuf = cipher.update(ibuf, 0, len);
                  if (obuf != null)
                      out.write(obuf);
              }
              byte[] obuf = cipher.doFinal();
              if (obuf != null)
                  out.write(obuf);
          }
      }
  }
  
  </code></pre>
  <p>the error occurred during decryption is</p>
  <pre><code>java.security.InvalidKeyException: Parameters missing
      at com.sun.crypto.provider.CipherCore.init(CipherCore.java:469)
      at com.sun.crypto.provider.AESCipher.engineInit(AESCipher.java:313)
      at javax.crypto.Cipher.implInit(Cipher.java:805)
      at javax.crypto.Cipher.chooseProvider(Cipher.java:867)
      at javax.crypto.Cipher.init(Cipher.java:1252)
      at javax.crypto.Cipher.init(Cipher.java:1189)
      at Encrypt.decryptWithEcb(Encrypt.java:46)
      at Encrypt.main(Encrypt.java:11)
  </code></pre>
  <p>how can I solve it?</p>