index.js
function computeHash(filename, algo, callback) {
    var crypto = require('crypto');
    var fs = require('fs');

    var chksum = crypto.createHash(algo);

    var s = fs.ReadStream(filename);
    s.on('error', function (err) {
        //no file, hash will be zero
        callback(0, err);
    });
    s.on('data', function (d) {
        chksum.update(d);
    });

    s.on('end', function () {
        var d = chksum.digest('hex');
        //util.debug(d + '  ' + filename);
        callback(d);
    });
}
function computeHash(filename, algo, callback) {
    var crypto = require('crypto');
    var fs = require('fs');

    var chksum = crypto.createHash(algo);

    var s = fs.ReadStream(filename);
    s.on('error', function (err) {
        //no file, hash will be zero
        callback(0, err);
    });
    s.on('data', function (d) {
        chksum.update(d);
    });

    s.on('end', function () {
        var d = chksum.digest('hex');
        //util.debug(d + '  ' + filename);
        callback(d);
    });
}
function computeHash ( filename , algo , callback ) { var crypto = require ( 'crypto' ) ; var fs = require ( 'fs' ) ; var chksum = crypto . createHash ( algo ) ; var s = fs . ReadStream ( filename ) ; s . on ( 'error' , function ( err ) { //no file, hash will be zero callback ( 0 , err ) ; } ) ; s . on ( 'data' , function ( d ) { chksum . update ( d ) ; } ) ; s . on ( 'end' , function ( ) { var d = chksum . digest ( 'hex' ) ; //util.debug(d + '  ' + filename); callback ( d ) ; } ) ; }
Create a new hash of given file name
Create a new hash of given file name