diff --git a/wizard-work/spark/VERIFICATION.txt b/wizard-work/spark/VERIFICATION.txt new file mode 100644 index 0000000..bfd79fb --- /dev/null +++ b/wizard-work/spark/VERIFICATION.txt @@ -0,0 +1,19 @@ +VERIFICATION TEST: SHA256 TOOL +================================ + +Test 1: /etc/hostname +Expected: 1c7ae0f30a68699c38441fd54bfbe20aed8e0c7c8793e25db41d2ff169b9639c +Tool Output: 1c7ae0f30a68699c38441fd54bfbe20aed8e0c7c8793e25db41d2ff169b9639c +Match: YES + +Test 2: /etc/passwd +Expected: 24a9d154e8b4556887f514b99bcd92c4d15fefbf284ff7ad481dad412849bd24 +Tool Output: 24a9d154e8b4556887f514b99bcd92c4d15fefbf284ff7ad481dad412849bd24 +Match: YES + +Test 3: Error handling for missing file +Expected: exit code 1, error message printed +Result: exit_code=1, "Error: /nonexistent not found" printed +Match: YES + +CONCLUSION: Tool verified correct against system sha256sum utility. \ No newline at end of file diff --git a/wizard-work/spark/sha256_tool.py b/wizard-work/spark/sha256_tool.py new file mode 100644 index 0000000..3f5c453 --- /dev/null +++ b/wizard-work/spark/sha256_tool.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +"""SHA256 file hash calculator - quick utility for integrity verification.""" +import hashlib +import sys +from pathlib import Path + +def calc_sha256(file_path: str) -> str: + """Calculate SHA256 hash of a file.""" + h = hashlib.sha256() + with open(file_path, 'rb') as f: + for chunk in iter(lambda: f.read(8192), b''): + h.update(chunk) + return h.hexdigest() + +if __name__ == '__main__': + if len(sys.argv) < 2: + print("Usage: sha256_tool.py ", file=sys.stderr) + sys.exit(1) + + path = Path(sys.argv[1]) + if not path.exists(): + print(f"Error: {path} not found", file=sys.stderr) + sys.exit(1) + + print(calc_sha256(str(path))) \ No newline at end of file