trySolveChallenge static method
int?
trySolveChallenge(
- ChallengeInfo challengeInfo, [
- int startNonce = 0,
- int? endNonceExclusive
Implementation
static int? trySolveChallenge(ChallengeInfo challengeInfo, [int startNonce = 0, int? endNonceExclusive]){
int nonce = startNonce;
String result = "";
while(endNonceExclusive == null || nonce < endNonceExclusive){
result = challengeInfo.challengeAlgorithm.hashToHexFunc(challengeInfo.token + ':' + nonce.toRadixString(16));
if(ChallengeAlgorithm.hexStringCompliesWithComplexity(result, challengeInfo.complexity)){
return nonce;
}
nonce++;
}
return null;
}