captcha
captcha copied to clipboard
How to get the content in the picture?
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.
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());
}