Free Student Projects


Human Test


Human Test, a CGI script written in the Perl language, is based on the ideas of The CAPTCHA Project. It generates distored text that most humans can read, but computers cannot to prevent automated robots from submitting forms. Software similar to this is starting to become widely used throughout the Internet, and is currently in place on major websites such as Yahoo! to prevent automated sign-ups.

Human Test captcha


Before you can use FirstProductions Human Test, be sure that your web site passes the minimum requirements:

Installation: Step 1: Uncompress the Package

First, you will need to uncompress the software package using WinZip or similar unzipping software. You should have a directory tree similar to this:

CGI (directory)
DATA (directory)
|__images (directory)
|__(various PNG files)

Installation: Step 2: Configure the Script

First open captchatest.cgi (the example script) in main CGI directory. Be sure that the first line of the script matches the path to Perl for your server. The path to Perl is usually similar to: /usr/bin/perl or /usr/local/bin/perl. Be sure not to remove the #! before the path to Perl. If you are unsure of the path to Perl, contact your server administrator.

Next, open in a text editor. This is the Human Test library used by the example script. You can also use this library in your own scripts for easy access to the Human Test functions (generateCode and checkCode). Here is a guide to configuring the options in the Settings section:

Installation: Step 3: Upload Files to Server

After configuring the script, create a folder in your “cgi-bin” for the files in the CGI directory. Upload the files in the CGI directory to your new folder on your web server in ASCII mode. Make thecaptchatest.cgi file executable by CHMODing it as 755. Next, create the web-accessible folder you configured captcha_webfolder, and give it appropriate permissions so the script will be able to write files to it. Then, create the captcha_datafolder you specified in the configuration section outside of your web-accessible folders. Give it write permissions and upload the files in the DATA directory to this folder. Give the codes.txt database write permissions.

Installation: Step 4: Testing the Script

Now that you have uploaded the files, it is time to see if it worked. In a web browser, navigate to the URL of the example script (captchatest.cgi). If there is an error, see the troubleshooting section of the documentation. If it works, go on to the Usage section.


There are two functions that you can call in – generateCode and checkCode. The example script demonstrates how to use these two functions. Here is an explanation of the functions.

generateCode($length) will generate a random sequence of letters and numbers of the specified length. It will then encrypt the sequence using md5. The md5 crypt is what the function returns. The function also outputs a PNG image of the code sequence to the output folder. The md5 crypt is the filename without the .png suffix. The function will add the md5 crypt to the database in the data folder with a timestamp, and expire old codes from the database. If a crypt is not returned, then a file error occured.

checkCode($code,$crypt) will check a code against the md5 crypt and code database. There are several possible values that can be returned:

1 : Passed – the entered sequence is correct and the crypt is valid and was found in the database.
0 : Code not checked – a file error occured.
-1 : Failed: code expired – the code was found in the database but it was expired.
-2 : Failed: invalid code (not in database) – the code was not found in the database either because it expired, was already used, or it is invalid.
-3 : Failed: invalid code (code does not match crypt) – the entered sequence is incorrect and the crypt has been removed from the database.

For more information about using these functions, please refer to the example script included with this package.

Updated – we have just released an extensive tutorial showing how to integrate the Human Test library into an existing script. To read it, please go to the FormMail Example on our website.

Troubleshooting Guide

500 Internal Server Error
Possible causes of a 500 Internal Server Error:
• The path to Perl in line one of the captchatest.cgi file is incorrect. Contact your server administrator on consult your server’s documentation to find out your path to Perl.
• Files were not uploaded in ASCII mode. Transfer the files to your server again in ASCII mode.
• The permissions of captchatest.cgi were not set to executable. Set the permissions of captchatest.cgi to executable (CHMOD 755).
• The file was not found. If you renamed, name it back to

404 File Not Found
Check the URL that you used to access captchatest.cgi and try again.

403 Forbidden
The permissions for captchatest.cgi were not set to executable (CHMOD 755).

Broken Image
If the example script displays a broken image, check the captcha_outputfolder and captcha_webfolder settings in the configuration section.

“Code not checked/generated (file error)”
Check the settings in the configuration section to be sure that they point to the correct folders, files, and paths.

Download Source Code:

download project code