import hashlib import os from pyfsig import * def dane_pliku(plik): with open(plik, "rb") as plik_binarny: dane = plik_binarny.read() naglowek = dane[:32] wielkosc = len(dane) / 1024 # w kb suma_sha1 = hashlib.sha1(dane).hexdigest() suma_md5 = hashlib.md5(dane).hexdigest() # sprawdzenie content-type matches = find_matches_for_file_header(file_header=naglowek) return suma_sha1, suma_md5, wielkosc, matches directory = "/home/adasiek/Documents" if not os.path.exists(directory): print(f"Directory {directory} doesn't exist") exit(1) for dirpath, dirname, files in os.walk(directory): print(f"Katalog {dirpath}:") for any_file in files: pliczek = dirpath+"/"+any_file sha1, md5, rozmiar, lista_content_type = dane_pliku(pliczek) print(f"Plik {any_file} ma rozmiar: {rozmiar} i {md5=} {sha1=} / {lista_content_type=}")