Add checksum verification for portable backups

This commit is contained in:
thePR0M3TH3AN
2025-07-01 21:43:52 -04:00
parent 6faead9f9a
commit c10e2380e5
5 changed files with 71 additions and 11 deletions

View File

@@ -1,9 +1,18 @@
import hashlib
import json
from pathlib import Path
from utils import checksum
def test_json_checksum():
data = {"b": 1, "a": 2}
expected = hashlib.sha256(
json.dumps(data, sort_keys=True, separators=(",", ":")).encode()
).hexdigest()
assert checksum.json_checksum(data) == expected
def test_calculate_checksum(tmp_path):
file = tmp_path / "data.txt"
content = "hello world"