Reputation: 1
Actually I'm on calculating crc using flutter. It's okey but I didn't get the expected result. I want just the value of the last sublist not the values of all the sublists. output Screenshot
In my case, I want just the last list : [ad]. this is my code:
List getRandomBytes() {
final listbytes = [
0xDC,
0x2E,
0x20,
0xF3,
0x20,
0x0E,
0xBF,
0x0A,
0x31,
0x39,
0x31,
0xF9,
0x0F, //
0x31,
0x5D,
0xFD,
0xE4,
0x19,
0xB4
];
List list3 = [];
for (int i = 0; i < 19; i++) {
List list4 = [(listbytes[i] ^ listbytes[i + 1]).toRadixString(16)];
list3 = List.from(list4);
print(list3);
}
return list3;
}
thanks in advance for your help
Upvotes: 0
Views: 90
Reputation: 23164
I believe you just want
[(listbytes[listbytes.length - 2] ^ listbytes[listbytes.length - 1]).toRadixString(16)]
I don't see the point of the loop really.
Upvotes: 1