update method
Implementation
void update(Uint8List message, int offset, int len) {
if (0 == len) {
return;
}
int remainingLength = 0;
if (0 != _bufferPos) {
// commenced, incomplete buffer
// complete the buffer:
remainingLength = Const.blockLengthBytes - _bufferPos;
if (remainingLength < len) {
// full buffer + at least 1 byte
_buffer = _arrayCopy(message, offset, _buffer, _bufferPos, remainingLength);
_t0 += Const.blockLengthBytes;
if (_t0 == 0) {
// if message > 2^64
_t1++;
}
_compress(_buffer, 0);
_bufferPos = 0;
_buffer.fillRange(0, _buffer.length, 0);
} else {
_buffer = _arrayCopy(message, offset, _buffer, _bufferPos, len);
_bufferPos += len;
return;
}
}
// process blocks except last block (also if last block is full)
int messagePos;
final int blockWiseLastPos = offset + len - Const.blockLengthBytes;
// block wise 128 bytes
for (messagePos = offset + remainingLength; messagePos < blockWiseLastPos; messagePos += Const.blockLengthBytes) {
// without buffer:
_t0 += Const.blockLengthBytes;
if (_t0 == 0) {
_t1++;
}
_compress(message, messagePos);
}
// fill the buffer with left bytes, this might be a full block
_buffer = _arrayCopy(message, messagePos, _buffer, 0, offset + len - messagePos);
_bufferPos += (offset + len) - messagePos;
}