views:

368

answers:

2

Hi Friends

I want javascript for Image captcha in html code.
Whcih generates images dynamically and match the given character with image characters. Before entering into the new page it should have to check whether both are same or not
I want to create it in my own, How i can achieve it?

Thanks in Advance,
Praveen J

+3  A: 

Use recaptcha. It's what stackoverflow uses!

jeffamaphone
+4  A: 

I want javascript for Image captcha in html code. Whcih generates images dynamically and match the given character with image characters. Before entering into the new page it should have to check whether both are same

Whilst you could conceivably write some shapes to a <canvas>, SVG or VML element — or even (on non-IE browsers) create an image with a ‘data:’ URL created from pixel values —  there is no point.

Any wholly client-side approach to captcha is already compromised because it needs to know the ‘right’ answer to check against. An attacker can just run the JavaScript themselves to find out the answer. Or just turn JavaScript off to avoid the checks.

To do captchas you need server-side scripting, which the attacker does not have access to, to do the work.

bobince
bobince is right. You would not use Javascript to create your captcha. The attacker and parse the Javascript easily to see the input before the captcha was even created.
JP
ya i agree your point... that's 100% true, then is it possible with php
praveenjayapal
Certainly. You could dump some letters into an image using imagefttext() then spit them out to the browser using imagegif(). See http://de.php.net/manual/en/book.image.php for PHP's image-handling functions.
bobince
It's a non-trivial task to make the text difficult to machine-read, though, so it might be a good idea to go with an existing library or service. The others' suggestion of Recaptcha is a reasonable one.
bobince