I have byte array and I need get checksum:
let bytes : [UInt8] = [0xC4, 0x03, 0x01, 0x09, 0x03]
I try this code but it did not help me:
let result = 256 - dataByte.checksum
extension Data {
var checksum: Int {
return self.map { Int($0) }.reduce(0, +) & 0xff
}
}
My friend who is the developer try to get checksum on Kotlin, like this:
var checksum = 0
for (i in 0..lastIndex) {
checksum = checksum xor this[i].toInt()
}
return checksum
And he got this result 0x0B and I need the same result only on swift 4.