Skip to content

Commit

Permalink
fix padding error
Browse files Browse the repository at this point in the history
See py-pdf#1221 for details.
  • Loading branch information
alper111 authored Nov 11, 2022
1 parent 0b2b3ec commit d47ab90
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PyPDF2/_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def decrypt(self, data: bytes) -> bytes:
iv = data[:16]
data = data[16:]
aes = AES.new(self.key, AES.MODE_CBC, iv)
if len(data) % 16:
from Crypto.Util.Padding import pad
data = pad(data, 16)
d = aes.decrypt(data)
if len(d) == 0:
return d
Expand Down

0 comments on commit d47ab90

Please sign in to comment.