#image #verification #dynamically #generate

captcha-rs

Generate verification images dynamically

23 releases

Uses new Rust 2024

0.3.0 Jan 25, 2026
0.2.11 Jan 10, 2025
0.2.10 Jun 1, 2023
0.2.8 Mar 21, 2023
0.1.7 Mar 18, 2022

#365 in Images

Download history 477/week @ 2025-10-15 529/week @ 2025-10-22 308/week @ 2025-10-29 600/week @ 2025-11-05 586/week @ 2025-11-12 342/week @ 2025-11-19 566/week @ 2025-11-26 557/week @ 2025-12-03 616/week @ 2025-12-10 338/week @ 2025-12-17 160/week @ 2025-12-24 566/week @ 2025-12-31 588/week @ 2026-01-07 721/week @ 2026-01-14 850/week @ 2026-01-21 785/week @ 2026-01-28

3,049 downloads per month
Used in next-web-utils

MIT license

185KB
320 lines

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

Using complexity method

Complexity Light Mode / Noise Filter Dark Mode / Noise Filter
Level 1 img-light img-dark
Level 2 img-light img-dark
Level 3 img-light img-dark
Level 4 img-light img-dark
Level 5 img-light img-dark
Level 6 img-light img-dark
Level 7 img-light img-dark
Level 8 img-light img-dark
Level 9 img-light img-dark
Level 10 img-light img-dark

Example

Add the following dependency to the Cargo.toml file:

[dependencies]
captcha-rs = "0.3.0"

And then get started in your main.rs:

use captcha_rs::CaptchaBuilder;

fn main() {
	
	let captcha = CaptchaBuilder::new()
		.length(5)
		.width(130)
		.height(40)
		.dark_mode(false)
		.complexity(1) // min: 1, max: 10
		.compression(40) // min: 1, max: 99
		.build();
	
	println!("text: {}", captcha.text);
	println!("base_img: {}", captcha.to_base64());
	
}

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.

Dependencies

~22MB
~526K SLoC