captcha-rs
captcha-rs is a library that generate verification images dynamically.
Example pictures are as follows:
![]() |
![]() |
![]() |
|---|---|---|
![]() |
![]() |
![]() |
Using complexity method
| Complexity | Light Mode / Noise Filter | Dark Mode / Noise Filter |
|---|---|---|
| Level 1 | ![]() |
![]() |
| Level 2 | ![]() |
![]() |
| Level 3 | ![]() |
![]() |
| Level 4 | ![]() |
![]() |
| Level 5 | ![]() |
![]() |
| Level 6 | ![]() |
![]() |
| Level 7 | ![]() |
![]() |
| Level 8 | ![]() |
![]() |
| Level 9 | ![]() |
![]() |
| Level 10 | ![]() |
![]() |
Using Visual Enhancements and Bot Deterrence
| Effect | Image example |
|---|---|
| Drop Shadow | ![]() |
| Heavy Interference | ![]() |
| Mild Distortion | ![]() |
| Heavy Distortion | ![]() |
Example
Add the following dependency to the Cargo.toml file:
[]
= { = "0.5.0", = ["stateless"] }
And then get started in your main.rs:
use CaptchaBuilder;
Stateless Verification (Serverless)
With the stateless feature enabled, you can generate a time-bound JWT token that contains a secure hash of the captcha solution. This allows you to verify the user's input on a different server or at a later time without storing the solution in a database or session.
use ;
Run
# Dev
# Build
# Test
Performance
The library is highly optimized for fast image generation. The table below represents benchmarks tested with varying configurations (measured per image):
| Configuration | Time per Image | Core Settings |
|---|---|---|
| Default | ~53 µs |
length=5, 130x40 |
| High Complexity | ~404 µs |
length=5, 200x70, complexity=10 |
| High Distortion | ~157 µs |
length=5, 200x70, distortion=15 |
| Extreme Security | ~1.10 ms |
length=8, 300x100, complexity=10, distortion=20, drop_shadow, high interference |
Note: Benchmarks run on a single thread using cargo bench. Performance will vary based on hardware, but standard generation should easily exceed thousands of images per second.
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.






























