I spent a bit of time investigating how to edit XML files of ConfigWizard of infineon. Application itself is written in QT, it loads these config files in XML that look something like this

<?xml version="1.0" encoding="UTF-8"?>
<ifxmlcfg version="2.0.3">
  <checksum>15e7131e59eb9d6f1af158870e9c922d4a280ff885fe2caf5b4f278bcc0fcda2</checksum>
  <horizontalcontainer ...>
     ..
  </horizontalcontainer>
</ifxmlcfg>

Benefit of editing this file, is the ability to add custom knobs, and parameters to your application, or restrict some system settings that would be otherwise freely modifiable.

Computing checksum is fairly simple:

  1. find first occurence of </checksum> and include it and rest of the file (i.e. delete everything before </checksum>)
  2. replace \r\n with \n (this is likely done by the way that file is read)
  3. sha256 in hex encoding is checksum

It’s curious that part of the file before <checksum> is ignored, but that is irrelevant.

Expressed in python:

  with open(file_path, 'rb') as f:
    data = f.read()
  modified_data = data[data.index(b"</checksum>"):].replace(b"\r\n", b"\n")
  hash_func = hashlib.sha256()
  hash_func.update(modified_data)
  return hash_func.hexdigest()

electronics