Skip to content

Instantly share code, notes, and snippets.

@jwhitehorn
Created March 5, 2019 21:24
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 jwhitehorn/d65ae99053c80035d3dd10ddc8696358 to your computer and use it in GitHub Desktop.
Save jwhitehorn/d65ae99053c80035d3dd10ddc8696358 to your computer and use it in GitHub Desktop.
this.tryHash = function(midstate, half, data, hash1, target, nonce){
data[3] = nonce;
this.sha.reset();
var h0 = this.sha.update(midstate, data).state; // compute first hash
for (var i = 0; i < 8; i++) hash1[i] = h0[i]; // place it in the h1 holder
this.sha.reset(); // reset to initial state
var h = this.sha.update(hash1).state; // compute final hash
if (h[7] == 0) {
var ret = [];
for (var i = 0; i < half.length; i++)
ret.push(half[i]);
for (var i = 0; i < data.length; i++)
ret.push(data[i]);
return ret;
} else return null;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment