|We don't bite newbies here... much|
XOR'ing to calculate a hex checksumby c4onastick (Friar)
|on Jan 28, 2008 at 17:13 UTC||Need Help??|
c4onastick has asked for the
wisdom of the Perl Monks concerning the following question:
I need to calculate the hex checksum of a bunch of digits to talk to a piece of equipment at work. According to the equipment manufacturers documented serial protocol, the checksum is the "bitwise inversion (XOR) of the one byte sum with FF hex".
Here's what I have so far, it seems to work fine except for the XOR operation, so my question is two-fold:
From my hand calculations (and I could be mistaken here, it's been a while since I've used anything besides base-10), the check sum for this command should be 67 hex (103 decimal) but it's comming up as 157 decimal. Any insights on this problem would be greatly appreciated! Also, any comments on cleaning up this script would be great too (it's pretty messy currently). Thanks in advance!