Skip to content

Commit

Permalink
Update function in map iterator
Browse files Browse the repository at this point in the history
Fixes #14.
Thanks to @mqus for solution.
Taken from PrivateBin/PrivateBin#193 (comment)
  • Loading branch information
r4sas committed Jun 24, 2019
1 parent ac58fff commit 8aea956
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pbincli/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __decompress(self, s):
# nothing to do, just return original data
return s
elif self._version == 1:
return zlib.decompress(bytearray(map(ord, b64decode(s.encode('utf-8')).decode('utf-8'))), -zlib.MAX_WBITS)
return zlib.decompress(bytearray(map(lambda c:ord(c)&255, b64decode(s.encode('utf-8')).decode('utf-8'))), -zlib.MAX_WBITS)
else:
raise PBinCLIException('Unknown compression type provided in paste!')

Expand Down Expand Up @@ -182,6 +182,7 @@ def decrypt(self):
cipher_message = json_decode(self.__decompress(cipher.decrypt_and_verify(cipher_text, cipher_tag)).decode())

self._text = cipher_message['paste'].encode()

if 'attachment' in cipher_message and 'attachment_name' in cipher_message:
self._attachment = cipher_message['attachment']
self._attachment_name = cipher_message['attachment_name']
Expand All @@ -197,6 +198,7 @@ def decrypt(self):
text = SJCL().decrypt(cipher_text, password)

if len(text):
if self._debug: print("Decoded Text:\t{}\n".format(text))
self._text = self.__decompress(text.decode())

if 'attachment' in self._data and 'attachmentname' in self._data:
Expand Down

0 comments on commit 8aea956

Please sign in to comment.