I am trying to replicate the file hashing of MobileSheetsPro, an Android app, where there is a hashcodes.txt which includes a hash for each file, as well as the path, last modified date and filesize. We'll just focus on the hashing part.
So for the random song I uploaded here if you want to try it for yourself, I am using the murmurhash-native
npm package to convert it to a buffer and then hash it like so:
const fs = require("fs");
const { promisify } = require("util");
const { murmurHash } = require("murmurhash-native");
const readFileAsync = promisify(fs.readFile);
async function hashcodeObjFromFilePath(filepath) {
const buf = await readFileAsync(filepath);
const h = murmurHash(buf);
console.log(h);
}
This prints out a hash of 4275668817
when using the default seed of 0 and 3020822739
when using the seed 0xc58f1a7b
as a second argument.
The problem: the app seems to calculate it differently. The developer wrote the following, but I don't see that exact function in the code he linked:
Check this out: github link
Those are the classes I've utilized. I call Hashing.goodFast32Hash(HASH_KEY)) where HASH_KEY is equal to 0xC58F1A7B.
EDIT I've got more infos from the dev:
I call Files.hash(file, Hashing.goodFast32Hash(HASH_KEY)); Using the return value from that, I call "asInt()" on the HashCode object that is returned. So it's a signed integer value (negative values are just fine). And yes, HASH_KEY is the seed value passed to the function.
Since I'm not good at Java I still have no idea to replicate this in node-js...
That's all the info I have, folks. Anyone see where I'm going wrong?