bytes_to_dump = length if length > 0x10: bytes_to_dump = 0x10 outhash = SHA1(listToString(key)[0:0x40]) for i in range(0, bytes_to_dump): ret += chr(ord(outhash[i]) ^ ord(inbuf[offset])) offset += 1 manipulate(key) length -= bytes_to_dump return ret def SHA1(data): m = hashlib.sha1() m.update(data) return m.digest() pkgcrypt.register_sha1_callback(SHA1) def listPkg(filename): with open(filename, 'rb') as fp: data = fp.read() offset = 0 header = Header() header.unpack(data[offset:offset+len(header)]) print header print assert header.type == 0x00000001, 'Unsupported Type' if header.itemCount > 0: print 'Listing: "' + filename + '"' print "+) overwrite, -) no overwrite" print