unpad function
Implementation
Uint8List unpad(Uint8List padded) {
int unpaddedLen = (padded[0] << 8) + padded[1];
if (unpaddedLen == 0 || unpaddedLen > padded.length - 2) {
throw Exception('Invalid padding');
}
return padded.sublist(2, 2 + unpaddedLen);
}