hashStrings static method

Future<Uint8List> hashStrings(
  1. Stream<String> stream, {
  2. Uint8List? key,
  3. int? outlen,
})

Computes a generic hash of specified length for given stream of string values and optional key.

Implementation

static Future<Uint8List> hashStrings(Stream<String> stream,
    {Uint8List? key, int? outlen}) async {
  outlen ??= Sodium.cryptoGenerichashBytes;
  final state = Sodium.cryptoGenerichashInit(key, outlen);
  try {
    await for (var value in stream) {
      Sodium.cryptoGenerichashUpdate(state, utf8.encoder.convert(value));
    }
    return Sodium.cryptoGenerichashFinal(state, outlen);
  } finally {
    calloc.free(state);
  }
}