stream static method

List<int> stream(
  1. List<int> key,
  2. List<int> nonce,
  3. List<int> dst, {
  4. int nonceInplaceCounterLength = 0,
})

Generates a stream of pseudo-random bytes using the ChaCha stream cipher.

This function generates a stream of pseudo-random bytes by encrypting a nonce and key with the ChaCha stream cipher algorithm. The generated stream is then XORed with the dst data, resulting in the encrypted output. It also provides the option to incorporate a nonce inplace counter.

Parameters:

  • key: The encryption key as a List
  • nonce: A unique nonce as a List
  • dst: The destination List
  • nonceInplaceCounterLength: An optional parameter to specify the length of the nonce inplace counter (default is 0, meaning no nonce inplace counter).

Returns:

  • The dst List

Note: This function securely zeros the dst data before writing the generated stream and should be used for generating secure random data.

Implementation

static List<int> stream(List<int> key, List<int> nonce, List<int> dst,
    {int nonceInplaceCounterLength = 0}) {
  zero(dst);
  return streamXOR(key, nonce, dst, dst,
      nonceInplaceCounterLength: nonceInplaceCounterLength);
}