Skip to main content

Crate caprs

Crate caprs 

Source
Expand description

Generate image-based CAPTCHA challenges and verify responses.

Click CAPTCHAs use text or shapes. Slide and drag CAPTCHAs cut a piece from a background, and rotate CAPTCHAs ask the user to realign a circular crop. Keep the answer on the server and send the client only the images and any display metadata it needs. Use the original image coordinates for verification.

use caprs::click;

let captcha = click::Captcha::new(click::Options::default(), click::Symbols::bundled_text()?)?;
let (images, answer) = captcha.generate()?.into_parts();
let hint = images.prompt().to_data_url()?;
assert!(hint.starts_with("data:image/png;base64,"));
assert!(!answer.verify(&[], 0));

Re-exports§

pub use image;

Modules§

click
Generate ordered point-and-click puzzles using text labels or raster shapes.
rotate
Generate a circular image puzzle that the user rotates to match a reference.
slide
Generate horizontal slide or free-drag puzzles from whole background images.

Structs§

Challenge
A generated pair of images and the answer the application keeps server-side.
Image
A generated image with a default encoding and access to the uncompressed pixels.
Images
The public images for one CAPTCHA challenge.
Point
A point in image pixels, measured from the top left with y increasing down.
Rect
A rectangle described by an image-space corner and pixel dimensions.
Size
The width and height of an image or region in pixels.

Enums§

CaptchaError
An invalid CAPTCHA configuration or a failure to generate a challenge.
Format
The default encoding of a generated image.
ImageError
Failure while encoding or saving a generated image.