Given a byte array
byte[] someBytes = { 0xFF, 0xFE, 0xFE, 0xFF, 0x11, 0x00 ,0x00 ,0x00 ,0x00}
What's the best to add up all the bytes? Manually adding all of the bytes by hand as hex numbers would yield 40B on my above example so preferably I'd like to end up with something like:
byte[] byteSum = { 0x04, 0x0B }
Actually, all I really need is the 0x0B part (Used for checksum). Checksum is calculated by 0x0B XOR 0x55 (Which yields 0x5E) in this case.
I understand this isn't a normal addition of bytes, but this is how the checksum is calculated.
Manually looping through the byte array and adding them results in an integer sum.
What's the most concise way of doing this?
0x040B % 0x0100 == 0x000BThe modulo operator divides one number with the other and returns the rest of the division.