Skip to content

Instantly share code, notes, and snippets.

@lucien-loua
Created November 14, 2023 20:25
Show Gist options
  • Select an option

  • Save lucien-loua/37f02d5d2f5b46c8f5018bdf0a54a166 to your computer and use it in GitHub Desktop.

Select an option

Save lucien-loua/37f02d5d2f5b46c8f5018bdf0a54a166 to your computer and use it in GitHub Desktop.
This script finds a sha256 hash starting with 5 zeroes

₿itcoin concept

const crypto = require('crypto')
let nonce = 0;
while (true) {
const data = nonce.toString();
const hash = crypto.createHash('sha256');
hash.update(data);
const hashResult = hash.digest('hex');
if (hashResult.startsWith('00000')) {
console.log(hashResult);
break;
}
nonce++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment