https://stackoverflow.com/a/18658613/779159は、組み込みの暗号化ライブラリとストリームを使用してファイルの md5 を計算する方法の例です。
var fs = require('fs');
var crypto = require('crypto');
// the file you want to get the hash
var fd = fs.createReadStream('/some/file/name.txt');
var hash = crypto.createHash('sha1');
hash.setEncoding('hex');
fd.on('end', function() {
hash.end();
console.log(hash.read()); // the desired sha1sum
});
// read all file and pipe it (write it) to the hash object
fd.pipe(hash);
しかし、ストリームを使用する効率を維持しながら、上記のコールバックを使用する代わりに ES8 async/await を使用するように変換することは可能ですか?