Library for provide captchas
imagemagick
To build the library and run tests
$ rebar get-deps compile
$ rebar eunit skip_deps=true
Copy the images used for captcha at priv/images
, exist one special image for watermark watermark.png
is required. Setup the images config at priv/captcha.config
.
-spec new(NumberElements::non_neg_integer(), Lang::binary()) -> list().
1> ecaptcha_image:new(2,<<"en">>).
[{<<"token">>, Token},{<<"text">>,<<"Where is Calamardo?">>},{<<"images">>,[Base64,Base64]}]
When a human select the an image, you check if is correct sending Token and the position selected of the images list.
-spec check(JWT::binary(), Position::non_neg_integer()) -> boolean().
1> ecaptcha_image:check(Token, 0).
true
2> ecaptcha_image:check(Token, 1).
false