Home > Captcha-Easy

Captcha-Easy

Captcha-Easy is a project mainly written in PERL and SHELL, based on the View license.

Simple and fast and easy to use captcha

NAME Captcha::Easy - Simple and fast captcha

VERSION Version 0.03

SYNOPSIS use Captcha::Easy;

    my $captcha = Captcha::Easy->new(
    temp   => '/path/to/storage',
    reuse  => 1, # reuse expired files
    salt   => 'your secret',
    font   => '/path/to/font.ttf',
    expire => 60*30, # 30 min
    );
    my $hash = $captcha->make;
    my ($w1,$w2,$rest) = split //,$hash,3;
    print qq{<img src="http://path.to.temp/$w1/$w2/$rest.png" />};

...

my $code = $captcha->check($word,$hash);
    if    ($code ==  1) { valid }
    elsif ($code ==  0) { wrong word }
    elsif ($code == -1) { word correct, but captcha was already used (i.e. file removed) }
    elsif ($code == -2) { word correct, but captcha was expired (i.e. file mtime < time - $captcha->{epire} ) }
    else                { something strange happens }

new (%args) Args: font, temp, reuse, expire, salt, debug, length

word([$length]) Generate captcha word

check Args: $code, $hash

Returns 1 if $code is a valid text for $hash

make Creates CAPTCHA and returns hash code for this CAPTCHA

AUTHOR Mons Anderson, ""

COPYRIGHT & LICENSE Copyright 2009 Mons Anderson, all rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.