Search code examples
hashhexasciichecksum

Calculate a checksum for a file


I have a csv file and I am trying to calculate a checksum for it.

The documentation says that I need to convert char values to decimals using this table:

enter image description here

The formula is ASCII("Character") - 48.

So, 'D' would be 20. Because in ASCII 'D' is 68 and if we subtract 48 from it, we will have 20.

Then there is this example of converted values in the documentation:

enter image description here

They somehow converted DF to 223 but I calculated it to be 42 (20 + 22) according to the table they provided.

They even somehow converted 96 to 150.

What can I be missing?


Solution

  • Turns out they did not follow the Table 3 mapping. Instead they were simply converting the given hex to an int.

    In python, it would look like this:

    int('DF', 16)
    

    which would give 223.