Created
June 19, 2020 13:16
-
-
Save neruthes/b55836d50a971fe8aa42833eec51fbe9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const CryptoJS = require('crypto-js'); | |
var inputUuid = 'e7587bd1-bb94-4949-9a75-7e50e0079a97'.toUpperCase().replace(/\-/g, ''); | |
var claimer = 'Neruthes'; | |
var payload1 = `UUIDClaimProtocol:v1:${inputUuid}:${claimer}`; | |
var payload2 = ''; | |
// var bestHashParamHex = '0000000000000'; | |
var bestHashParamHex = '0000000F7B135'; | |
// var bestHash = (new Array(64)).fill('F').join(''); | |
var bestHash = '0000003BE9A5A226D4C88E208367E2E5C6CE70024DDF3CD78CE60F084FFE4C4E'; | |
// The best is the hash which has the smallest number | |
// Hash function: SHA-256 | |
var isThisHashBetterThan = function (comparingHash, baseHash) { | |
if (parseInt(comparingHash, 16) <= parseInt(baseHash, 16)) { | |
return true; | |
} else { | |
return false; | |
}; | |
}; | |
var leftpad = function (str, len, pad) { | |
if (str.length >= len) { | |
return str; | |
} else { | |
return (new Array(len-str.length)).fill(pad).join('') + str; | |
}; | |
}; | |
var getHash = function (i) { | |
var paramHex = leftpad(i.toString(16).toUpperCase(), 13, '0'); | |
var payload2 = `${payload1}:${paramHex}`; | |
var hash = CryptoJS.SHA256(payload2).toString(CryptoJS.enc.Hex).toUpperCase(); | |
return { | |
param: paramHex, | |
hash: hash | |
}; | |
}; | |
var resumePoint = 0x13D5737; | |
for (var i = resumePoint; i < resumePoint + 2**24 || i < 2**40; i++) { // MAX 52 bits in JS to be safe | |
// for (var i = 0; i < 2**16; i++) { // MAX 52 bits in JS to be safe | |
var currentHash = getHash(i); | |
process.stdout.write(`\rCurrent progress: [${currentHash.param}] ${currentHash.hash}`); | |
if (isThisHashBetterThan(currentHash.hash, bestHash)) { | |
process.stdout.write(`\r`); | |
console.log('\nFound a better hash.'); | |
console.log(`Previous hash: [${bestHashParamHex}] ${bestHash}`); | |
console.log(`Current hash: [${currentHash.param}] ${currentHash.hash}\n`); | |
bestHash = currentHash.hash; | |
bestHashParamHex = currentHash.param; | |
}; | |
delete currentHash; | |
}; | |
console.log('\n\n\n'); | |
console.log(`Got the best hash for uuid "${inputUuid}" and claimer "${claimer}":`); | |
console.log(`Input for SHA-256: "${payload1}:${bestHashParamHex}"`); | |
console.log(`Best hash: ${bestHash}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment