Last active
December 13, 2015 19:49
-
-
Save jrgm/4965554 to your computer and use it in GitHub Desktop.
was it truncated over http?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var crypto = require('crypto'); | |
var targetSha = '25f7bcf998cc3747cad755d53dec4c6698aad834'; | |
var candidates = { | |
includeJs_2425cff7: { | |
filename: 'whatis-25f7bcf.at.2425cff7aeb9c8d4b4b930168d341e3b401a4d89', | |
knownSha: '7b7d2e96f46271f79a83395ed1486a69c2135d89', | |
}, | |
includeJs_3621544d: { | |
filename: 'whatis-25f7bcf.at.3621544d2b252c1dfa26cdbb96258e00e807ce45', | |
knownSha: '269240cf28176d0307cba74a99b2330bef656de3', | |
}, | |
}; | |
Object.keys(candidates).forEach(function(key) { | |
var filename = candidates[key].filename; | |
var knownSha = candidates[key].knownSha; | |
var content = fs.readFileSync(filename, 'utf8'); | |
console.log('--- Looking at slices of', filename, 'for', targetSha, '---'); | |
if (content.length === Buffer.byteLength(content)) { | |
console.log('content.length === Buffer.byteLength', | |
content.length, Buffer.byteLength(content), filename); | |
} | |
for (var idx = 0; idx < content.length; ++idx) { | |
var partial = content.substr(idx); | |
var sha1 = crypto.createHash('sha1').update(partial).digest("hex"); | |
// console.log(content.length, idx, sha1); | |
// if (idx >= content.length - 4) { | |
// console.log(content.length, idx, partial, sha1); | |
//} | |
if (sha1 === knownSha) { | |
console.log("*** Expected ***", sha1, idx); | |
} | |
if (sha1 === targetSha) { | |
console.log("*** WINNER ***", sha1, idx); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment