Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3402

BadPaddingException while decrypting file

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 2.0.1
    • Fix Version/s: None
    • Component/s: Crypto
    • Labels:
      None

      Description

      Here I am getting issue while trying decrypt file using PDFBox


      java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
      at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptDataAESother(SecurityHandler.java:291)
      at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:152)
      at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:449)
      at org.apache.pdfbox.pdfparser.COSParser.parseFileObject(COSParser.java:764)
      at org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:721)
      at org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:652)
      at org.apache.pdfbox.pdfparser.COSParser.parseDictObjects(COSParser.java:612)
      at org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:215)
      at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:249)
      at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:972)
      at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:908)


      Decryptor.java
      String oPasswd = password + OWNER_PDF_ENCRYTPION_KEY_SUFFIX;
      		
      		try {
      			PDDocument reader = PDDocument.load(new FileInputStream(src),oPasswd);
      			reader.setAllSecurityToBeRemoved(true);
      			reader.save(dest);
      			reader.close();
      			return true;
      		    }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ArjunKaushal03 Arjun Kaushal
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: