1、利用node原生封装一个求文件hash的方法
const { createHash } = require('crypto'); const { createReadStream } = require('fs'); const getFileMd5 = (filePath) => { return new Promise((resolve) => { const md5sum = createHash('md5'); const stream = createReadStream(filePath); stream.on('data', (chunk) => md5sum.update(chunk)); stream.on('end', () => resolve(md5sum.digest('hex'))); }); };标签:node,知识点,const,stream,chunk,md5sum,--- From: https://www.cnblogs.com/venblogs/p/17182164.html