diff --git a/st_eur.sha1 b/st_eur.sha1 new file mode 100644 index 00000000..10822861 --- /dev/null +++ b/st_eur.sha1 @@ -0,0 +1 @@ +4c950473fa0694cea04eed517e05631f529b35ed st_eur.nds diff --git a/st_jp.sha1 b/st_jp.sha1 new file mode 100644 index 00000000..e56aee2f --- /dev/null +++ b/st_jp.sha1 @@ -0,0 +1 @@ +eaee3602b8a2235211b2e20cdcd4cb357956a264 st_jp.nds diff --git a/tools/sha1.py b/tools/sha1.py new file mode 100644 index 00000000..8cd6edd8 --- /dev/null +++ b/tools/sha1.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +from pathlib import Path +import argparse +import hashlib +import sys + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + +parser = argparse.ArgumentParser(description="Computes and verifies a SHA1 checksum") +parser.add_argument('file', help="Input file to verify") +parser.add_argument('-c', type=str, dest='checksum_file', required=False, help='Checksum file') +args = parser.parse_args() + +file_path = Path(args.file) +checksum_path = Path(args.checksum_file) + +with checksum_path.open('r') as file: + target_sha1, _ = file.readline().split(' ', 1) + +with file_path.open('rb') as file: + file_sha1 = hashlib.sha1(file.read()).hexdigest() + +if target_sha1 != file_sha1: + eprint(f"{file_path}: FAILED") + exit(1) +else: + eprint(f"{file_path}: OK")