Created
February 1, 2020 23:16
-
-
Save hathix/1bff5eb89b92b424436fdccddfadd902 to your computer and use it in GitHub Desktop.
Bitcoin mining simulation
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
// Simulating Bitcoin's Proof-of-Work mining algorithm | |
// The challenge: choose a nonce that, when appended to "hello", | |
// yields an MD5 hash with at least 4 leading zeroes | |
for (let i = 0; i < 1000000; i++) { | |
out = md5("hello" + i); | |
if (out.startsWith("0000")) { | |
console.log(i, out) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment