digestFile method

Future<Uint8List> digestFile(
  1. String algorithmName,
  2. File file, {
  3. int bufferSize = EvpDigest.defaultBufferSize,
})
inherited

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);