summaryrefslogtreecommitdiff
path: root/protocal/checksum.go
diff options
context:
space:
mode:
Diffstat (limited to 'protocal/checksum.go')
-rw-r--r--protocal/checksum.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/protocal/checksum.go b/protocal/checksum.go
new file mode 100644
index 0000000..ce096ff
--- /dev/null
+++ b/protocal/checksum.go
@@ -0,0 +1,15 @@
+// +build !windows
+
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2020 jet tsang zeon-git. All Rights Reserved.
+ */
+package protocal
+
+func CheckSum(checksum []byte) uint8 {
+ var sum uint16 = 0
+ for _, v := range checksum {
+ sum += uint16(v)
+ }
+ return (uint8)(^sum)
+}