stream method

void stream(
  1. List<int> dst
)

Generates and writes keystream to the destination.

This method generates a stream of keystream bytes and writes them to the destination List<int>. The keystream is continuously generated as needed, with the option to specify whether it is intended for encryption or decryption.

Parameters:

  • dst: The destination List<int> where the generated keystream will be written.
  • forEncryption: A boolean flag indicating whether the keystream is intended for encryption. If set to true, the keystream is used for encryption; if set to false, it is used for decryption.

Note: This method is essential for generating the keystream needed for encryption or decryption in the Counter (CTR) mode.

Implementation

void stream(List<int> dst) {
  for (var i = 0; i < dst.length; i++) {
    if (_bufpos == _buffer.length) {
      _fillBuffer();
    }
    dst[i] = _buffer[_bufpos++];
  }
}