The crypto module of node.js (at the time of this writing at least) is not still deemed stable and so the API may change. In fact, the methods that everyone in the internet
Further polish, ECMAScript 2015
function checksumFile(algorithm, path) { return new Promise((resolve, reject) => fs.createReadStream(path) .on('error', reject) .pipe(crypto.createHash(algorithm) .setEncoding('hex')) .once('finish', function () { resolve(this.read()) }) ) }