pub fn solve_challenge(
challenge: &str,
salt: &str,
algorithm: Option<AltchaAlgorithm>,
max_number: Option<u64>,
start: u64,
) -> Result<u64, Error>Expand description
Solves a challenge by brute force. Used for testing.
§Arguments
challenge: The challenge to solve.salt: The salt used in the challenge.algorithm: The hash algorithm used. Optional.max_number: The maximum number to try. Optional.start: The starting number.
returns: Result<u64, Error> The solution or error.
§Examples
use jiff::{Timestamp, ToSpan};
use altcha_lib::{create_challenge, solve_challenge, ChallengeOptions};
let challenge = create_challenge(
ChallengeOptions{
hmac_key: "super-secret",
expires: Some(Timestamp::now().checked_add(5_i64.minutes()).unwrap()),
..Default::default()
}).expect("internal error");
let res = solve_challenge(&challenge.challenge, &challenge.salt,
Some(challenge.algorithm), Some(challenge.maxnumber), 0);