Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the content in the picture? #23

Open
Siceberg opened this issue Oct 10, 2023 · 1 comment
Open

How to get the content in the picture? #23

Siceberg opened this issue Oct 10, 2023 · 1 comment

Comments

@Siceberg
Copy link

Hi,

How to use this crate to complete CAPTCHA certification? Generally, it is necessary to determine whether the content input by the user is consistent with the content in the picture, but I have not found a way to obtain the content in the picture.

@Rushmore75
Copy link

You have to create a variable with the captcha before you save it.

use std::path::Path;
use captcha::{Captcha, filters::Noise, Difficulty, gen, CaptchaName, by_name};

fn main() {
    // ============================================
    let mut cap = Captcha::new();
    cap.add_chars(5)
        .apply_filter(Noise::new(0.7))
        .view(220, 120)
        .save(Path::new("output.png")).unwrap();
    println!("{}", cap.chars_as_string());

    // ============================================
    let hard = gen(Difficulty::Hard);
    hard.save(Path::new("hard.png")).unwrap();
    println!("{}", hard.chars_as_string());

    // ============================================
    let ameila = by_name(Difficulty::Hard, CaptchaName::Amelia);
    ameila.save(Path::new("ameila.png")).unwrap();
    println!("{}", ameila.chars_as_string());

    let lucy = by_name(Difficulty::Hard, CaptchaName::Lucy);
    lucy.save(Path::new("lucy.png")).unwrap();
    println!("{}", lucy.chars_as_string());

    let mila = by_name(Difficulty::Hard, CaptchaName::Mila);
    mila.save(Path::new("mila.png")).unwrap();
    println!("{}", mila.chars_as_string());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants