secure captcha logo
Important: domain name change. We are moving from web-utils.eu to securecaptcha.net. If you use our service, change host name in your code.

Secure CAPTCHA - installation, configuration, API and code samples

This page contains technical information about integrating the Secure CAPTCHA inside the HTML or XHTML form.

Overview

Secure CAPTCHA, when integrated into online form, allows to distinguish between form submition made by human and machine (robot, bot, script, program, etc.).

On this page, we accept following convention. To integrate Secure CAPTCHA with your server, you will have to complete following steps:
 1. Configuration
 2. Embedding question into the HTML/XHTML form
 3. Validating the answer
  3a. Offline validation
  3a. Online validation

1. Configuration

We assume, that you have already created account at SecureCAPTCHA.net, added a site and obtained your siteID and privateKey.

2. Embedding questions into the form

To insert CAPTCHA element into your form you must insert a special peace of code into your form serving function (or wherever else you want). That peace of code will make a challenge request. Challenge request is a HTTP request to the address http://www.securecaptcha.net/captcha/generateResponse with following parameters: Response contains the following (lines are divided with \n character): Hash, mac and timestamp values will be used for a challenge response validation. You must store them in some way to reload them upon the form submition. It is better not to reveal them to the end-user, so do not put them in the form hidden values. User session object is a good place for them, if your session implementation is secure.

You should print fragment directly to your page (perhaps with appropriate encoding transform). Do not try to assume any structure of the fragment. It may change in the future.

You must put fragment in such place on your page, that it will be visible to the user. You may assign custom CSS styles, but you must ensure that every part of the fragment is easily visible to the user. CAPTCHA image looks better with border (ie. 1px solid black). You may surround CAPTCHA fragment with <div class="captchaContainer"></div> and define CSS rule .captchaContainer img {border: 1px solid black; } .

Here you can find example scripts doing the challenge request written in some commonly used programming languages.

Show python code

Show Java code

Show PHP code

3. Validating the answer

Upon form submition you should make validation to check, whether the answer submitted by the user is correct. To make a validation, you should know hash, mac and timestamp generated in step 2. You should also have the answer submitted by the user.

Before validation you may reject some submitions comparing timestamp value with current time and reject this submitions that has been solved longer then some time (ie. 3 minutes). Before implementing that, ensure, that your server clock time is accurate. If not, you may provide your own timestamp checking.

There are two ways of validation: offline (takes place on your server, requires md5 digest computation) and online (by a HTTP request).

3a. Offline validation

Note, that you may perform an offline validation only if you are sure, that hash value used in this step is the same value that been generated by you in step 2. You can not use offline validation ie. if hash has been generated on the client side (Java Script).

To make offline validation calculate hmac with key=privateKey, message=hash+answer+timestamp (+ is a string concatenation), digestAlgorithm=md5, oped=0x5C, ipad=0x36. If result as a lower hex string is equal to the mac, user has entered a correct answer.

Before making offline validation, you should check timestamp value. If your system clock is not accurate, you should provide your own timestamp checking or perform online validation.

Here you can find example scripts doing the challenge request written in some commonly used programming languages.

Show python code

Show Java code

Show PHP code

3b. Online validation

To make online validation, make HTTP request to the http://www.securecaptcha.net/captcha/validate with following parameters: Received response contains the following (lines are separated with \n): If status is 1, answer is correct and you may assume, that form has been submitted by a human.

Here you can find example scripts doing the challenge request written in some commonly used programming languages.

Show python code

Show Java code

Show PHP code