captcha-rs 0.2.1

Generate verification images dynamically
Documentation

captcha-rs

Captcha-rs crate test issues Downloads MIT License Captcha-rs documentation dependency status

captcha-rs is a library that generate verification images dynamically.

Example pictures are as follows:

img-light-1.png img-light-2.png img-light-3.png
img-dark-1.png img-dark-2.png img-dark-3.png

Example

Add the following dependency to the Cargo.toml file:

[dependencies]
captcha-rs = "0.2.1"

And then get started in your main.rs:

use captcha_rs::{Captcha, CaptchaBuilder};

fn main() {
	let dark_mode = true;
	let text_length = 5;
	let width = 130;
	let height = 40;
	
	// generate a captcha with the given parameters
	let captcha = Captcha::new(text_length, width, height, dark_mode);
	
	// generate a captcha using builder pattern
	let captcha = CaptchaBuilder::new()
		.length(5)
		.width(130)
		.height(40)
		.dark_mode(false)
		.build();
	
	println!("text: {}", captcha.text);
	println!("base_img: {}", captcha.base_img);
}

Run

# Dev
$ cargo run

# Build
$ cargo build

# Test
$ cargo test -- --nocapture

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in captcha-rs by you, shall be licensed as MIT, without any additional terms or conditions.