You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
I'm using version 1.06 of pyPDF3.
Currently pyPDF3 is only capable of handling "algorithm 1 and 2 encrypted pdfs". I would love to have also the other algorithms decodes. For my use case decrypting the document info header would be sufficient.
The following code sample demonstrates the problem (having the above mentioned pdf downloaded and renamed to encrypt.pdf):
from PyPDF3 import PdfFileReader
with open('encrypt.pdf', 'rb') as f:
pdf_file = PdfFileReader(f)
doc_info = pdf_file.getDocumentInfo()
This code throws the error: PyPDF3.utils.PdfReadError: file has not been decrypted
Adding an additional decrypt statement like this:
from PyPDF3 import PdfFileReader
with open('encrypt.pdf', 'rb') as f:
pdf_file = PdfFileReader(f)
if pdf_file.isEncrypted:
pdf_file.decrypt('')
doc_info = pdf_file.getDocumentInfo()
leads to: NotImplementedError: only algorithm code 1 and 2 are supported. This PDF uses code 5
For your reference the content of the relevant variables in this case:
I'm using version 1.06 of pyPDF3.
Currently pyPDF3 is only capable of handling "algorithm 1 and 2 encrypted pdfs". I would love to have also the other algorithms decodes. For my use case decrypting the document info header would be sufficient.
An encrypted file can be downloaded from here:
https://cloud.3dissue.net/24308/24333/24567/65779/Position_4.21-211104-DE-web-20211203082446.pdf
The following code sample demonstrates the problem (having the above mentioned pdf downloaded and renamed to
encrypt.pdf
):This code throws the error:
PyPDF3.utils.PdfReadError: file has not been decrypted
Adding an additional decrypt statement like this:
leads to:
NotImplementedError: only algorithm code 1 and 2 are supported. This PDF uses code 5
For your reference the content of the relevant variables in this case:
I found "qpdf" which is able to handle the encryption of this files. The decryption algorithm of qpdf can be found in file https://raw.githubusercontent.com/qpdf/qpdf/main/libqpdf/QPDF_encryption.cc
Would be great if somebody could catch up from here and implement the decryption in pypdf3.
The text was updated successfully, but these errors were encountered: