generateHashFile function

Future<Digest> generateHashFile(
  1. File file, [
  2. Hash hashMethod = sha1
])

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

Implementation

Future<Digest> generateHashFile(
  File file, [
  Hash hashMethod = sha1,
]) async {
  var output = AccumulatorSink<Digest>();
  var input = hashMethod.startChunkedConversion(output);

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

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