Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pack the permissions (the /P entry) as unsigned long, fix #186 #352

Merged
merged 7 commits into from
Jan 7, 2020
4 changes: 3 additions & 1 deletion pdfminer/pdfdocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ def compute_encryption_key(self, password):
password = (password + self.PASSWORD_PADDING)[:32] # 1
hash = md5.md5(password) # 2
hash.update(self.o) # 3
hash.update(struct.pack('<L', self.p)) # 4
# See https://github.com/pdfminer/pdfminer.six/issues/186
unsigned_p = self.p if self.p > 0 else self.p + (1 << 32)
pietermarsman marked this conversation as resolved.
Show resolved Hide resolved
hash.update(struct.pack('<L', unsigned_p)) # 4
hash.update(self.docid[0]) # 5
if self.r >= 4:
if not self.encrypt_metadata:
Expand Down