unpad method
Implementation
Iterable<int> unpad(int blockSize, Iterable<int> input,
{/* String | List<int> */ label = const <int>[]}) {
if (label is! List<int>) {
label = utf8.encode(label);
}
final labelHash = hasher.convert(label).bytes;
if (input.length % blockSize != 0) {
throw Exception(
'Invalid message length. Must be multiple of blockSize $blockSize. Got ${input.length}');
}
int messageBlockSize = blockSize - (2 * labelHash.length) - 2;
final numBlocks = input.length ~/ blockSize;
final out = Uint8List(numBlocks * messageBlockSize);
int outLen = 0;
for (int i = 0; i < numBlocks; i++) {
Iterable<int> block = input.take(blockSize);
input = input.skip(blockSize);
final unpaddedMsg = unpadBlock(blockSize, block, labelHash: labelHash);
out.setAll(i * messageBlockSize, unpaddedMsg);
outLen += unpaddedMsg.length;
}
if (outLen == out.length) {
return out;
}
return out.take(outLen);
}