12 lines
246 B
Go
12 lines
246 B
Go
package s19
|
|
|
|
import "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
|
|
}
|