/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/python/py-502-31-013/main.py
25 строк
782 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
import hashlib import json from pathlib import Path def build_manifest(folder: Path) -> dict: manifest = {} for f in folder.rglob("*"): if f.is_file(): h = hashlib.sha256() h.update(f.read_bytes()) manifest[str(f.relative_to(folder))] = h.hexdigest() return manifest def verify_manifest(folder: Path, manifest_path: Path) -> list[str]: expected = json.loads(manifest_path.read_text(encoding="utf-8")) errors = [] for rel, digest in expected.items(): path = folder / rel if not path.exists(): errors.append(f"нет файла: {rel}") continue if sha256_file(path) != digest: errors.append(f"хеш не совпадает: {rel}") return errors