Captcha(3pm) | User Contributed Perl Documentation | Captcha(3pm) |
Authen::Captcha - Perl extension for creating captcha's to verify the human element in transactions.
use Authen::Captcha; # create a new object my $captcha = Authen::Captcha->new(); # set the data_folder. contains flatfile db to maintain state $captcha->data_folder('/some/folder'); # set directory to hold publicly accessible images $captcha->output_folder('/some/http/folder'); # Alternitively, any of the methods to set variables may also be # used directly in the constructor my $captcha = Authen::Captcha->new( data_folder => '/some/folder', output_folder => '/some/http/folder', ); # create a captcha. Image filename is "$token.png" my $token = $captcha->generate_code($number_of_characters); # check for a valid submitted captcha # $code is the submitted letter combination guess from the user # $token is the submitted token from the user (that we gave them) my $results = $captcha->check_code($code,$token); # $results will be one of: # 1 : Passed # 0 : Code not checked (file error) # -1 : Failed: code expired # -2 : Failed: invalid code (not in database) # -3 : Failed: invalid code (code does not match token) ##############
The captcha produced by this module is rather weak compared to other modules available. You are advised to update to GD::SecurityImage, which provides API-compatible interface in GD::SecurityImage::AC module.
Authen::Captcha provides an object oriented interface to captcha file creations. Captcha stands for Completely Automated Public Turing test to tell Computers and Humans Apart. A Captcha is a program that can generate and grade tests that:
- most humans can pass. - current computer programs can't pass
The most common form is an image file containing distorted text, which humans are adept at reading, and computers (generally) do a poor job. This module currently implements that method. We plan to add other methods, such as distorted sound files, and plain text riddles.
GD (see http://search.cpan.org/~lds/GD-2.11/) Digest::MD5 (standard perl module)
In most common situations, you'll also want to have:
A web server (untested on windows, but it should work) cgi-bin or mod-perl access Perl: Perl 5.00503 or later must be installed on the web server. GD.pm (with PNG support)
Download the zipped tar file from:
http://search.cpan.org/search?dist=Authen-Captcha
Unzip the module as follows or use winzip:
tar -zxvf Authen-Captcha-1.xxx.tar.gz
The module can be installed using the standard Perl procedure:
perl Makefile.PL make make test make install # you need to be root
Windows users without a working "make" can get nmake from:
ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe
data_folder => '/some/folder', # required output_folder => '/some/http/folder', # required expire => 300, # optional. default 300 width => 25, # optional. default 25 height => 35, # optional. default 35 images_folder => '/some/folder', # optional. default to lib dir keep_failures => 0, # optional, defaults to 0(false) debug => 0, # optional. default 0
It can also be called in array context to retrieve the string of characters used to generate the captcha (the string the user is expected to respond with). This is useful for debugging. ex.
"($token,$chars) = $captcha->generate_code( $number_of_characters );"
$code is the submitted letter combination guess from the user
$token is the submitted token from the user (that we gave them)
If the $code and $token are correct, the image file and database entry will be removed.
If the $token matches one in the database, and "keep_failures" is false (the default), the image file and database entry will be removed to avoid repeated attempts on the same captcha.
$results will be one of:
1 : Passed 0 : Code not checked (file error) -1 : Failed: code expired -2 : Failed: invalid code (not in database) -3 : Failed: invalid code (code does not match token)
sound file captcha: Incorporating distorted sound file creation.
The Captcha project:
http://www.captcha.net/
The origonal perl script this came from:
http://www.firstproductions.com/cgi/
Seth T. Jackson, <sjackson@purifieddata.net>
Josh I. Miller, <jmiller@purifieddata.net>
First Productions, Inc. created the cgi-script distributed under the GPL which was used as the basis for this module. Much work has gone into making this more robust, and suitable for other applications, but much of the origonal code remains.
Fixes were reported and contributed by various people, see Changes file for a complete list.
Copyright 2003, First Productions, Inc. (FIRSTPRODUCTIONS HUMAN TEST 1.0)
Copyright 2003 by Seth Jackson
Copyright 2012 by Paolo Rossi, Lubomir Rintel, Chris Dunlop, Gert Schepens and Ernesto Hernández-Novich
This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. (see license.txt).
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2022-06-08 | perl v5.34.0 |