generateHash method

Future<Digest> generateHash(
  1. {Hash hashMethod = sha1}
)

Method that generates a hash code from the contents of a file.

Implementation

Future<Digest> generateHash({
  Hash hashMethod = sha1,
}) async {
  var output = AccumulatorSink<Digest>();
  var input = hashMethod.startChunkedConversion(output);

  await for (final val in openRead()) {
    input.add(val);
  }

  input.close();
  return output.events.single;
}