stream method
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 destinationList<int>
where the generated keystream will be written.forEncryption
: A boolean flag indicating whether the keystream is intended for encryption. If set totrue
, the keystream is used for encryption; if set tofalse
, 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++];
}
}