var crypto = require('crypto');
var fs = require('fs');
var file1 = process.argv[2];
var file2 = process.argv[3];
var sha1sum = function(input){
return crypto.createHash('sha1').update(JSON.stringify(input)).digest('hex')
};
var first = sha1sum(file1);
var second = sha1sum(file2);
console.log(first + ' ' + file1);
console.log(second + ' ' + file2);
if (first == second) {
console.log("the two hashes are equal");
} else {
console.log("the two hashes aren't equal");
}
The above is the current code I'm using. It takes in two file inputs and compares their hashes. However, when passing the same file from two different locations as arguments, they have different sha1 hashes. Is this supposed to happen, or is my code incorrect?