finish method

  1. @override
BLAKE2s finish(
  1. List<int> out
)
override

Finalizes the hash computation and stores the result in the provided out buffer.

Implementation

@override
BLAKE2s finish(List<int> out) {
  if (!_finished) {
    for (int i = _bufferLength; i < _blockSize; i++) {
      _buffer[i] = 0;
    }

    // Set last block flag.
    _flag[0] = BinaryOps.mask32;
    // Set last node flag if the last node in the tree.
    if (_lastNode) {
      _flag[1] = BinaryOps.mask32;
    }

    _processBlock(_bufferLength);
    _finished = true;
  }

  final List<int> tmp = List<int>.filled(32, 0);
  for (int i = 0; i < 8; i++) {
    BinaryOps.writeUint32LE(_state[i], tmp, i * 4);
  }
  out.setRange(0, out.length, tmp);
  return this;
}