doFinal method

  1. @override
int doFinal(
  1. Uint8List out,
  2. int outOff
)
override

Store the digest of previously given data in buffer out starting at offset outOff. This method returns the size of the digest.

Implementation

@override
int doFinal(Uint8List out, int outOff) {
  _f0.set(0xFFFFFFFF, 0xFFFFFFFF);
  _t0.sum(_bufferPos);
  if (_bufferPos > 0 && _t0.lo32 == 0 && _t0.hi32 == 0) _t1.sum(1);
  _compress(_buffer, 0);
  _buffer!.fillRange(0, _buffer!.length, 0); // clear buffer
  _internalState.fillRange(0, _internalState.length, 0);

  final packedValue = Uint8List(8);
  final packedValueData = packedValue.buffer.asByteData();
  for (var i = 0; i < _chainValue!.length && (i * 8 < _digestLength); ++i) {
    _chainValue![i].pack(packedValueData, 0, Endian.little);

    final start = outOff + i * 8;
    if (i * 8 < _digestLength - 8) {
      out.setRange(start, start + 8, packedValue);
    } else {
      out.setRange(start, start + _digestLength - (i * 8), packedValue);
    }
  }

  _chainValue!.fillRange(0, _chainValue!.length, 0);

  reset();

  return _digestLength;
}