Skip to main content

create_challenge

Function create_challenge 

Source
pub fn create_challenge(
    options: ChallengeOptions<'_>,
) -> Result<Challenge, Error>
Expand description

Creates a challenge for the client to solve.

§Arguments

  • options: ChallengeOptions defines the options for creating a challenge

returns: Result<Challenge, Error> The new challenge or error.

§Examples

use std::default;
use jiff::{Timestamp, ToSpan};
use altcha_lib::{create_challenge, ChallengeOptions};
let challenge = create_challenge(
    ChallengeOptions{
        hmac_key: "super-secret",
        expires: Some(Timestamp::now().checked_add(5_i64.minutes()).unwrap()),
        ..Default::default()
 });