stream static method
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 Listnonce
: A unique nonce as a Listdst
: The destination ListnonceInplaceCounterLength
: 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);
}