Hi Cyberdyne
I have made it so that it shows the progress -
http://privatepaste.com/683603b43bThe core of this code is:
// we want to find the passcode for this bitcoin address
var target = document.getElementById("targetaddress").value.toString().replace(/^\s+|\s+$/g, "");
//var target = "1Eq8Ucu2ugn4owQZ8RUybrA3Cm2Bo7Zzac";
// passphrase search data
var inputElements = document.getElementsByTagName("input");
var searchData = [];
for(var i = 0; i < inputElements.length; i++) {
if (inputElements[i].getAttribute("data-role") == "passPhraseChar") {
var value = inputElements[i].value.toString().replace(/^\s+|\s+$/g, "");
if (value != "") {
searchData.push(value);
}
}
}
//var searchData = ["a", "pP", "pP", "l", "e"];
// we will use a pubKeyHash for comparing when generating an address (this saves the step of base58 encoding when generating an address)
// decode address to base58 and extract just the pubKeyHash (so remove the first number and checksum at the end of the address)
var targetPubKeyHash = Bitcoin.Base58.decode(target);
targetPubKeyHash = targetPubKeyHash.splice(1, targetPubKeyHash.length - 5);
// calculate total combinations
var totalCombinations = 0;
var totalIterations = 0;
var divisors = new Array();
divisors[0] = 1;
for(var i = 0; i < searchData.length; i++) {
if (i === 0) {
totalCombinations = searchData[i].length;
totalIterations = totalCombinations;
} else {
totalCombinations = totalCombinations * searchData[i].length;
totalIterations += totalCombinations;
}
divisors[i + 1] = totalCombinations;
}
var amountOfTimesToUpdate = 1000;
var updateIncrements = totalCombinations / amountOfTimesToUpdate;
var nextUpdate = updateIncrements;
var i = 0;
(function asyncBitcoinAddressCheck() {
var checkphrase = "";
for(var n = 0; n < searchData.length; n++) {
var index = Math.floor(i / divisors[n]) % searchData[n].length;
checkphrase += searchData[n][index];
}
var bytes = Crypto.SHA256(checkphrase, { asBytes: true });
var btcKey = new Bitcoin.ECKey(bytes);
var pubKeyHash = btcKey.getPubKeyHash();
var found = true;
for(var j = 0; j < pubKeyHash.length; j++) {
if (pubKeyHash[j] != targetPubKeyHash[j]) {
found = false;
}
}
if (found) {
var privWif = btcKey.getBitcoinWalletImportFormat();
var bitcoinAddress = btcKey.getBitcoinAddress();
document.getElementById("brainbtcaddress").innerHTML = bitcoinAddress;
document.getElementById("brainbtcprivwif").innerHTML = privWif;
ninja.qrCode.showQrCode({
"brainqrcodepublic": bitcoinAddress,
"brainqrcodeprivate": privWif
});
document.getElementById("brainkeyarea").style.visibility = "visible";
alert("Password is " + checkphrase);
return;
}
if (i < totalCombinations) {
i++;
if (i > nextUpdate) {
nextUpdate += updateIncrements;
document.getElementById("bulktextarea2").value = "Checking combination " + (i + 1) + " out of " + totalCombinations + " (" + (Math.round( i / totalCombinations * 1000 ) / 10) + "%)";
setTimeout(asyncBitcoinAddressCheck, 0);
} else {
asyncBitcoinAddressCheck();
}
}
})();
document.getElementById("bulktextarea2").value = "Checking combination " + totalCombinations + " out of " + totalCombinations + " (100%)";
Regards
Schalk