|
|
@@ -0,0 +1,22 @@ |
|
|
|
function fetchChallenge() { |
|
|
|
fetch("/challenge").then(response => { |
|
|
|
if (!response.ok) { |
|
|
|
alert(response.body) |
|
|
|
} |
|
|
|
localStorage.setItem("challengeString", response.body) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
function findMagic() { |
|
|
|
let challenge = localStorage.getItem("challenge") |
|
|
|
if (challenge !== "") { |
|
|
|
for (let i=0; true; i++) { |
|
|
|
let result = sha256.array(challenge + i.toString()) |
|
|
|
if (result[0] === 0 && result[1] === 0) { |
|
|
|
localStorage.setItem("magicString", i.toString()) |
|
|
|
return i.toString() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return "" |
|
|
|
} |