Created
March 5, 2019 21:24
-
-
Save jwhitehorn/d65ae99053c80035d3dd10ddc8696358 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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