I have a process that computes and checks the checksum in AIS messages, the checksum is the xor of all the bytes in the message expressed in hexadecimal format. At the moment I am turning both the calculated and included checksums into strings and comparing them, which seems a bit compute heavy. Is there a better way to compare the single byte calculation with its 2 byte hexadecimal representation? bytdata is the AIS message in a []byte{}.
j := i + 1
for ; j < leng ; j++ {
checkSum ^= (int)(bytdata[j])
}
checkBytes := fmt.Sprintf("%02X", checkSum)
if checkBytes == string(bytdata[(j+1):(j+3)]) {
// valid checksum......
etc
}