github.com/apernet/sing-tun@v0.2.6-0.20240323130332-b9f6511036ad/internal/clashtcpip/tcpip_compat.go (about) 1 package clashtcpip 2 3 func SumCompat(b []byte) (sum uint32) { 4 n := len(b) 5 if n&1 != 0 { 6 n-- 7 sum += uint32(b[n]) << 8 8 } 9 10 for i := 0; i < n; i += 2 { 11 sum += (uint32(b[i]) << 8) | uint32(b[i+1]) 12 } 13 return 14 }