Skip to content

Commit cf3aab4

Browse files
authored
ROB: Decrypt returns empty bytestring (#1258)
Closes #1245
1 parent baf0de1 commit cf3aab4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

PyPDF2/_encryption.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ def decrypt(self, data: bytes) -> bytes:
8585
data = data[16:]
8686
aes = AES.new(self.key, AES.MODE_CBC, iv)
8787
d = aes.decrypt(data)
88-
return d[: -d[-1]]
88+
if len(d) == 0:
89+
return d
90+
else:
91+
return d[: -d[-1]]
8992

9093
def RC4_encrypt(key: bytes, data: bytes) -> bytes:
9194
return ARC4.ARC4Cipher(key).encrypt(data)

0 commit comments

Comments
 (0)