remzi-arpacidusseau / ostep-homework

2.1k stars 999 forks source link

Ch. 45 checksum.py - changes output format to columns; fixes the readme #24

Open carlalbing opened 3 years ago

carlalbing commented 3 years ago

in the README file: fixes an error -D 2 should have been a -d 2 in an example changes the examples to use the new output format

in checksum.py reorders some code so that the data_size parameter is correct when the user uses -D to supply custom data

rearranges some code so that the printout of data values is in columns (rather than rows):
        for easier summing, xor-ing
        for cleaner display for larger values of -d  (avoids line wrapping)

Here is the new order; much easier to do checksums on a column of data. Decimal: Hex: Bin: 216 0xd8 0b11011000 194 0xc2 0b11000010 107 0x6b 0b01101011 66 0x42 0b01000010

carlalbing commented 3 years ago

If the user specifies data values via -D 1,2,3,4,5,6,7 it seems that the data size should say 7 whereas it currently stays at 4 unless explicitly set via -s 7. This mod also fixes that issue. The big change, having the data in columns, is much handier for showing how the checksums work, as the binary numbers line up in a single column.