decodeRaw function
Implementation
Uint8List decodeRaw(Uint8List buffer) {
Uint8List payload = buffer.sublist(0, buffer.length - 4);
Uint8List checksum = buffer.sublist(buffer.length - 4);
Uint8List newChecksum = _sha256x2(payload);
if (checksum[0] != newChecksum[0] ||
checksum[1] != newChecksum[1] ||
checksum[2] != newChecksum[2] ||
checksum[3] != newChecksum[3]) {
throw new ArgumentError("Invalid checksum");
}
return payload;
}