pad method

Uint8List pad(
  1. int blockSize,
  2. Iterable<int> input
)
override

Implementation

Uint8List pad(int blockSize, Iterable<int> input) {
  if (blockSize > 255) {
    throw Exception('PKCS #7 only supports block sizes less than 256');
  }

  int numBlocks = (input.length + blockSize) ~/ blockSize;
  int outSize = numBlocks * blockSize;

  final ret = Uint8List(outSize);

  ret.setAll(0, input);
  for (int i = input.length; i < outSize; i++) {
    ret[i] = outSize - input.length;
  }

  return ret;
}