Created
April 14, 2018 22:24
-
-
Save saurfang/196b434f2a6ad5f1973384cebeef0670 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
| var answerHash = '0xdb81b4d58595fbbbb592d3661a34cdca14d7ab379441400cbfa1b78bc447c365'; | |
| // iterate through all possible uint8 | |
| for (var i = 0; i < 2 ** 8; i++) { | |
| var hex = i.toString(16); | |
| var padUint8 = web3.padLeft(hex, 2); | |
| var hash = web3.sha3(padUint8, {encoding: 'hex'}); | |
| if (hash == answerHash) { | |
| console.log(`Found: ${i}`); | |
| break; | |
| } | |
| } | |
| // compare keccak256 hash | |
| // pad to uint8 | |
| console.log('uint8: ' + web3.sha3(web3.padLeft((170).toString(16), 2), {encoding: 'hex'})); | |
| // pad to uint (uint256) | |
| console.log('uint256: ' + web3.sha3(web3.padLeft((170).toString(16), 64), {encoding: 'hex'})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment