anCaptcha
A No-JS, stateless captcha engine implemented in Rust. Originally designed for the darknet and Tor hidden services, to provide human verification without requiring JavaScript.
Core Engine
This crate provides the core logic for:
- Stateless Tokens: Authenticated encryption (ChaCha20-Poly1305) stores challenge state without server sessions.
- Resource Processing: JIT asset warming and noise injection to thwart automated solvers.
- Multi-Modal Challenges: Supports Rotate, Slider, and Find-the-Pair verification styles.
Usage
1. Initialize Asset Cache
It is recommended to initialize and warm up the cache during startup. Since warming up involves heavy image processing, use a blocking task if in an async environment. You can warm up only the styles you intend to use.
use ;
let cache = init_cache;
// Recommended: Warm up only the styles you need in a background thread
spawn;
2. Generate a Challenge
Initialize the engine with a 32-byte secret key (e.g., from an environment variable).
use ;
let secret = ; // Replace with real secret
let ac = new;
// Choose your style: generate_rotate, generate_slider, or generate_pair
let bundle = ac.generate_slider.expect;
// bundle.html contains the combined HTML and CSS <style> block
// bundle.token must be included in your form submission
3. Verify Submission
You can verify the raw form-data directly (automatic) or verify individual values.
// Automatic verification from a HashMap<String, Vec<String>>
let is_valid = ac.verify_request.unwrap_or;
Features
std: Enabled by default.rayon: Parallel asset pre-computation.
(c) 2026 Maverick. Apache-2.0.