I am having a hard time implementing a checksum in golang.
The checksum should sum [n]Bytes, mod the total with 256 and return the result as [2]byte
Checksum = ( 0x30 + 0x30 + 0x30 + 0x37 ) mod 0x0100 = 0xC7
Return :
byte[0] should be C = 0x43
byte[1] should be 7 = 0x37
Can you please guide me here. This is what I have sofar:
func generateCheckSum(bytesArr []byte) (checkSum1, checkSum2 byte) {
total := 0
for _,value := range bytesArr {
total += int(value)
}
mod := (total % 0x0100)
//From here I don't know how to split the 'mod' for checkSum1 and checkSum2
return
}
Regards
Pieter