RomPatcher.js icon indicating copy to clipboard operation
RomPatcher.js copied to clipboard

[FR] show source checksum from input patch

Open eadmaster opened this issue 1 year ago • 0 comments

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):

eadmaster avatar May 21 '24 02:05 eadmaster