update method

  1. @override
void update(
  1. Uint8List inp,
  2. int inpOff,
  3. int len
)
override

Add len bytes of data contained in inp, starting at position inpOff ti the digested input.

Implementation

@override
void update(Uint8List inp, int inpOff, int len) {
  if (len == 0) return;
  var remainingLength = 0;
  if (_bufferPos != 0) {
    remainingLength = _blockSize - _bufferPos;
    if (remainingLength < len) {
      _buffer!
          .setRange(_bufferPos, _bufferPos + remainingLength, inp, inpOff);
      _t0.sum(_blockSize);
      if (_t0.lo32 == 0 && _t0.hi32 == 0) _t1.sum(1);
      _compress(_buffer, 0);
      _bufferPos = 0;
      _buffer!.fillRange(0, _buffer!.length, 0); // clear buffer
    } else {
      _buffer!.setRange(_bufferPos, _bufferPos + len, inp, inpOff);
      _bufferPos += len;
      return;
    }
  }

  int msgPos;
  var blockWiseLastPos = inpOff + len - _blockSize;
  for (msgPos = inpOff + remainingLength;
      msgPos < blockWiseLastPos;
      msgPos += _blockSize) {
    _t0.sum(_blockSize);
    if (_t0.lo32 == 0 && _t0.hi32 == 0) _t1.sum(1);
    _compress(inp, msgPos);
  }

  _buffer!.setRange(0, inpOff + len - msgPos, inp, msgPos);
  _bufferPos += inpOff + len - msgPos;
}