Skip to content

Instantly share code, notes, and snippets.

@hathix
Created February 1, 2020 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hathix/1bff5eb89b92b424436fdccddfadd902 to your computer and use it in GitHub Desktop.
Save hathix/1bff5eb89b92b424436fdccddfadd902 to your computer and use it in GitHub Desktop.
Bitcoin mining simulation
// 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