createConsumer abstract method

GenericHashConsumer createConsumer({
  1. int? outLen,
  2. SecureKey? key,
})

Creates a StreamConsumer for generating a hash from a stream.

The returned GenericHashConsumer is basically a typed StreamConsumer, that wraps the generichash streaming APIs. Creating the consumer will call crypto_generichash_init, adding messages to it via GenericHashConsumer.addStream will call crypto_generichash_update for every event in the stream. After you are done adding messages, you can GenericHashConsumer.close it, which will call crypto_generichash_final internally and return the hash of the data.

Optionally, you can pass outLen to modify the length of the generated hash and key if you want to use the hash as MAC.

For simpler usage, if you only have a single input Stream and simply want to get the hash from it, you ca use stream instead.

See https://libsodium.gitbook.io/doc/hashing/generic_hashing#usage

Implementation

GenericHashConsumer createConsumer({
  int? outLen,
  SecureKey? key,
});