EncrypC_3.py 718 B

123456789101112131415161718192021222324252627
  1. def decrypt(self):
  2. # exact same as above function except in reverse
  3. cipher_object = AES.new(
  4. self.hashed_key_salt["key"], AES.MODE_CFB, self.hashed_key_salt["salt"]
  5. )
  6. self.abort() # if the output file already exists, remove it first
  7. input_file = open(self.user_file, "rb")
  8. output_file = open(self.decrypt_output_file, "xb")
  9. done_chunks = 0
  10. for piece in self.read_in_chunks(input_file):
  11. decrypted_content = cipher_object.decrypt(piece)
  12. output_file.write(decrypted_content)
  13. done_chunks += 1
  14. yield done_chunks / self.total_chunks * 100
  15. input_file.close()
  16. output_file.close()
  17. # clean up the cipher object
  18. del cipher_object