Skip to content

Instantly share code, notes, and snippets.

@gibatronic
Created September 6, 2017 02:32
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 gibatronic/2c3ac88afe06a9e2b0f2e9d42fb553b9 to your computer and use it in GitHub Desktop.
Save gibatronic/2c3ac88afe06a9e2b0f2e9d42fb553b9 to your computer and use it in GitHub Desktop.
const crypto = require('crypto');
let hash;
let index = 0;
function check() {
const data = hash.read().toString('hex');
hash.removeListener('readable', check);
if (data.substr(0, 10) != '0000000000') {
index++;
return process.nextTick(main);
}
console.log(data);
console.log(index);
}
function main() {
hash = crypto.createHash('sha256');
hash.on('readable', check);
hash.write(index.toString());
hash.end();
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment