encode method

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

Implementation

Uint8List encode(int blockSize, Iterable<int> input) {
  final inputLen = input.length;
  final output = Uint8List(blockSize);

  final inputBlock = Uint8List(inputLen + 4);
  inputBlock.setRange(0, inputLen, input);

  int i = 0;
  int offset = 0;
  while (offset < blockSize) {
    BigInt counter = BigInt.from(i);
    inputBlock.setRange(
        inputLen, inputLen + 4, bigIntToBytes(counter, outLen: 4));

    final outputBlock = hasher.convert(inputBlock).bytes;
    int end = offset + outputBlock.length;
    if (end > blockSize) {
      end = blockSize;
    }
    output.setRange(offset, end, outputBlock);
    offset = end;

    i++;
  }

  return output;
}