diff --git a/PyPDF2/_encryption.py b/PyPDF2/_encryption.py index 0eae5c4ff..f1302a3a3 100644 --- a/PyPDF2/_encryption.py +++ b/PyPDF2/_encryption.py @@ -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