marcrobledo / RomPatcher.js

An IPS/UPS/APS/BPS/RUP/PPF/xdelta ROM patcher made in HTML5.
https://www.marcrobledo.com/RomPatcher.js/
Other
653 stars 133 forks source link

[FR] show source checksum from input patch #69

Open eadmaster opened 1 month ago

eadmaster commented 1 month ago

Some patch formats provide a source checksum in the header (e.g. BPS)

This could save some time finding the right input rom, in case the hash is missing from the readme.

example python script to read the hash from a bps patch

def read_bps_header(filename):
    # https://github.com/blakesmith/rombp/blob/master/docs/bps_spec.md
    with open(filename, 'rb') as f:
        magic = f.read(4)
        if magic != b'BPS1':
            raise ValueError("Not a BPS patch")

        # Read source and target hashes
        source_crc32 = struct.unpack('<I', f.read(4))[0]
        target_crc32 = struct.unpack('<I', f.read(4))[0]

        print(f"Source CRC32: {source_crc32:08X}")
        print(f"Target CRC32: {target_crc32:08X}")

EDIT: other formats that should include the source checksum within the patch file itself (still unverified by me):