node md5

var crypto = require('crypto');
var fs = require('fs');

//从文件创建一个可读流
var stream = fs.createReadStream('./wu.jpg');
var fsHash = crypto.createHash('md5');

stream.on('data', function(d) {
    fsHash.update(d);
});

stream.on('end', function() {
    var md5 = fsHash.digest('hex');
    console.log("文件的MD5是:%s", md5);
});
var fs = require('fs');
var md5 = require('md5');

fs.readFile('./wu.jpg', function(err, buf) {
  console.log(md5(buf));
});
posted @ 2019-11-19 20:40  樱风凛  阅读(378)  评论(0编辑  收藏  举报