if not buf:
return buf
- try:
- idx = buf.index(b'Salted__')
- except ValueError:
- buf = self.encryption.decrypt(buf, last)
+ idx = buf.find(b'Salted__')
+ if idx == -1:
+ return self.encryption.decrypt(buf, last)
+
+ b1 = buf[:idx]
+ b2 = buf[idx:]
+ if b1:
+ buf = self.encryption.decrypt(b1, True)
else:
- b1 = buf[:idx]
- b2 = buf[idx:]
- if b1:
- buf = self.encryption.decrypt(b1, True)
- else:
- buf = b''
+ buf = b''
+
+ self.encryption.get_salt_str(b2)
+ self.encryption.init()
+ b2 = b2[len(self.encryption.salt_str):]
+ buf += self.__split_enc_file(b2, last)
- self.encryption.get_salt_str(b2)
- self.encryption.init()
- b2 = b2[len(self.encryption.salt_str):]
- buf += self.__split_enc_file(b2, last)
return buf
# class _Stream