squeeze method

Uint8List squeeze(
  1. int length
)

Extracts 'length' bytes. Can be called as many times as desired after absorption is finalized.

Implementation

Uint8List squeeze(int length) {
  if (!_squeezing) {
    finalizeAbsorption();
  }
  Uint8List output = Uint8List(length);
  int offset = 0;
  while (offset < length) {
    if (_bufferPos == _rate) {
      _keccakf();
      _extractBlock(_buffer);
      _bufferPos = 0;
    }
    int toCopy = _rate - _bufferPos;
    if (toCopy > length - offset) {
      toCopy = length - offset;
    }
    output.setRange(offset, offset + toCopy,
        _buffer.sublist(_bufferPos, _bufferPos + toCopy));
    _bufferPos += toCopy;
    offset += toCopy;
  }
  return output;
}