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

Py3: Correct use of string instead of bytes #15

Open
wants to merge 2 commits into
base: py3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyPdf/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def readStringFromStream(stream):
elif tok == b"r":
tok = b"\r"
elif tok == b"t":
tok = "\t"
tok = b"\t"
elif tok == b"b":
tok = b"\b"
elif tok == b"f":
Expand Down
5 changes: 3 additions & 2 deletions pyPdf/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,15 +903,16 @@ def _authenticateUserPassword(self, password):
p_entry = encrypt['/P'].getObject()
id_entry = self.trailer['/ID'].getObject()
id1_entry = id_entry[0].getObject()
real_U = encrypt['/U'].getObject().original_bytes
if rev == 2:
U, key = _alg34(password, owner_entry, p_entry, id1_entry)
return U == real_U, key
elif rev >= 3:
U, key = _alg35(password, rev,
encrypt["/Length"].getObject() // 8, owner_entry,
p_entry, id1_entry,
encrypt.get("/EncryptMetadata", BooleanObject(False)).getObject())
real_U = encrypt['/U'].getObject().original_bytes
return U == real_U, key
return U[:16] == real_U[:16], key

def getIsEncrypted(self):
return "/Encrypt" in self.trailer
Expand Down