digestFile method
Digests file by reading it in chunks, never loading it whole.
This is the safe way to hash an upload or an attachment of unknown size —
digest(alg, await file.readAsBytes()) would hold the entire file in
memory twice, once in Dart and once in native memory.
Use startDigest instead when the file's size is needed alongside its
digest, so the file is not measured in a separate call.
Implementation
Future<Uint8List> digestFile(
String algorithmName,
File file, {
int bufferSize = EvpDigest.defaultBufferSize,
}) =>
digestStream(algorithmName, file.openRead(), bufferSize: bufferSize);