checksum method
A hash of the file at path, as lowercase hex. algorithm is md5
(the default, as in Laravel), sha1, sha224, sha256, sha384 or
sha512.
Implementation
Future<String> checksum(String path, {String algorithm = 'md5'}) =>
_run(path, () async {
final crypto.Hash hash = switch (algorithm) {
'md5' => crypto.md5,
'sha1' => crypto.sha1,
'sha224' => crypto.sha224,
'sha256' => crypto.sha256,
'sha384' => crypto.sha384,
'sha512' => crypto.sha512,
_ => throw ArgumentError.value(
algorithm,
'algorithm',
'Use md5, sha1, sha224, sha256, sha384 or sha512',
),
};
final crypto.Digest digest = await hash
.bind(driver.readStream(_resolve(path)))
.first;
return digest.toString();
});