Skip to content

Commit

Permalink
Add murmurhash3 as possible hash
Browse files Browse the repository at this point in the history
Close #6.
  • Loading branch information
jakub-g committed Mar 27, 2014
1 parent 13019cd commit 58573c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/visitors/Hash.js
Expand Up @@ -35,10 +35,18 @@ Hash.prototype.onAfterOutputFileBuild = function (packaging, outputFile) {
};

Hash.prototype._computeHash = function (filePath) {
var hash = crypto.createHash(this.hash);
var content = grunt.file.read(filePath, {
encoding : null
});

if (this.hash == "murmur3") {
content = content.toString();
var digest = require('murmurhash-js').murmur3(content);
// murmur3 output is 32bit integer, convert it to base36 string (max. 7 chars from [0-9a-z])
return digest.toString(36);
}

var hash = crypto.createHash(this.hash);
hash.update(content);
return hash.digest('hex');
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -10,6 +10,7 @@
},
"main": "lib/main.js",
"dependencies": {
"murmurhash-js": "0.0.1",
"uglify-js": "2.4.13"
},
"devDependencies": {
Expand Down

0 comments on commit 58573c4

Please sign in to comment.