Last active
November 19, 2021 20:47
-
-
Save GGLinnk/2af3256c12f253c901c34c15a9806f99 to your computer and use it in GitHub Desktop.
PzzTool Autotest. Must be use with pzztool.py from https://github.com/Virtual-World-RE/NeoGF and unpacked pzz file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from argparse import ArgumentParser; | |
import pzztool | |
import hashlib | |
import json | |
import os | |
__author__ = "GGLinnk" | |
__copyright__ = "Copyright 2021 - Virtual World RE" | |
__license__ = "MIT" | |
__version__ = "1.1.0" | |
__maintainer__ = "GGLinnk" | |
__email__ = "[email protected]" | |
__status__ = "Production" | |
def argparser(): | |
parser = ArgumentParser(description='Test that decompression / compression are working') | |
parser.add_argument('input_path', metavar='INPUT', help='Path to folder containing compressed .dat file (unpacked pzz)') | |
return parser.parse_args() | |
if __name__ == '__main__': | |
listofinvalid = {'invalid-hash': {}, 'decomp-failed': []} | |
args = argparser() | |
for filename in os.listdir(args.input_path): | |
file = open(os.path.join(args.input_path, filename), 'rb') | |
original_bytes = file.read() | |
try: | |
recomp_bytes = pzztool.pzz_compress(pzztool.pzz_decompress(original_bytes)) | |
original_digest = hashlib.sha256(original_bytes).hexdigest() | |
recomp_digest = hashlib.sha256(recomp_bytes).hexdigest() | |
if original_digest != recomp_digest: | |
listofinvalid['invalid-hash'][filename] = {'original_digest': original_digest, 'recomp_digest': recomp_digest} | |
except: | |
listofinvalid['decomp-failed'].append(filename) | |
file.close() | |
with open('invalid_files.json', 'w') as file: | |
file.write(json.dumps(listofinvalid, indent=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment