Crate captcha [] [src]

Crate to generate CAPTCHAs.

Examples

   

For a more detailed list of predefined CAPTCHAS please have a look at by_name.

Create CAPTCHAs

The crate offers two ways to create CAPTCHAs. The first way is the most easiest one. Just one line of code is necessary to create a random CAPTCHA of a given category. The category can be either Easy, Medium or Hard. The size of the CAPTCHA is 220x120 pixels and the number of characters is randomly selected between 4 and 6 letters (inclusive).

use captcha::{gen, Difficulty};

gen(Difficulty::Easy).as_png();

To be more flexible you can build CAPTCHAs manually as well.

use captcha::Captcha;
use captcha::filters::{Noise, Wave, Dots};

Captcha::new()
    .add_chars(5)
    .apply_filter(Noise::new(0.4))
    .apply_filter(Wave::new(2.0, 20.0).horizontal())
    .apply_filter(Wave::new(2.0, 20.0).vertical())
    .view(220, 120)
    .apply_filter(Dots::new(15))
    .as_png();

Modules

filters

Filters to disturb and transform CAPTCHAs.

Structs

Captcha

A CAPTCHA.

Geometry

Represents the area which contains text in a CAPTCHA.

Enums

CaptchaName

Names of predefined CAPTCHAs.

Difficulty

The difficulty of a CAPTCHA.

Functions

by_name

Creates a predefined CAPTCHA by its name.

gen

Creates a random CAPTCHA with the given difficulty.