Lib.py 588 B

123456789101112131415161718192021222324
  1. import os
  2. import hashlib
  3. from definitions import ROOT_DIR
  4. # TODO: generate better test pcap (1000-2000 packets)
  5. test_pcap = ROOT_DIR + "/../resources/test/test.pcap"
  6. test_pcap_ips = ["192.168.189.143", "192.168.189.1"]
  7. def get_sha256(file):
  8. sha = hashlib.sha256()
  9. with open(file, 'rb') as f:
  10. while True:
  11. data = f.read(0x100000)
  12. if not data:
  13. break
  14. sha.update(data)
  15. return sha.hexdigest()
  16. def clean_up(controller):
  17. os.remove(controller.pcap_dest_path)
  18. os.remove(controller.label_manager.label_file_path)