package s19 import ( "encoding/hex" "strconv" ) func validateChecksum(line string, checksum byte) bool { sum := byte(0) for i := 2; i < len(line)-2; i += 2 { value, _ := strconv.ParseUint(line[i:i+2], 16, 8) sum += byte(value) } return ^sum == checksum } func computeChecksum(body string) byte { sum := byte(0) for i := 0; i < len(body); i += 2 { value, _ := hex.DecodeString(body[i : i+2]) sum += value[0] } return ^sum }