if not pos:
pos = self.bufpos+self.charpos
self.fp.seek(pos)
- ##print >>sys.stderr, 'poll(%d): %r' % (pos, self.fp.read(n))
self.fp.seek(pos0)
return
'''
while not self.results:
(pos, token) = self.nexttoken()
- ##print (pos,token), (self.curtype, self.curstack)
if (isinstance(token, int) or
isinstance(token, Decimal) or
isinstance(token, bool) or
'''
Recursively decipher X.
'''
- if isinstance(x, str):
+ if isinstance(x, bytearray) or isinstance(x,bytes):
return decipher(objid, genno, x)
decf = lambda v: decipher_all(decipher, objid, genno, v)
if isinstance(x, list):
if 'Filter' not in self.dic:
self.data = data
self.rawdata = None
- ##print self.dict
return
filters = self.dic['Filter']
if not isinstance(filters, list):
plaintext = AES.new(key,AES.MODE_CBC,ivector).decrypt(data)
# remove pkcs#5 aes padding
cutter = -1 * plaintext[-1]
- #print cutter
plaintext = plaintext[:cutter]
return plaintext
plaintext = AES.new(key,AES.MODE_CBC,ivector).decrypt(data)
# remove pkcs#5 aes padding
cutter = -1 * plaintext[-1]
- #print cutter
plaintext = plaintext[:cutter]
return plaintext
# end - hope this doesn't have bad effects
self.write(b'<<')
for key, val in obj.items():
- self.write(b'/%s' % key.encode('utf-8'))
+ self.write(str(LIT(key.encode('utf-8'))).encode('utf-8'))
self.serialize_object(val)
self.write(b'>>')
elif isinstance(obj, list):
def decryptBook(userkey, inpath, outpath):
if RSA is None:
- raise ADEPTError("PyCrypto or OpenSSL must be installed.")
+ raise ADEPTError("PyCryptodome or OpenSSL must be installed.")
with open(inpath, 'rb') as inf:
- #try:
serializer = PDFSerializer(inf, userkey)
- #except:
- # print "Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath))
- # return 2
- # hope this will fix the 'bad file descriptor' problem
with open(outpath, 'wb') as outf:
# help construct to make sure the method runs to the end
try: