CAPTCHA图片认证的一些资料

来源:互联网 发布:淘宝qq群怎么做 编辑:程序博客网 时间:2024/05/14 05:59

在网站开发,为了区分是人输入的东西还是计算机自动输入的东西。经常用到CAPTCHA图片认证。

针对每种语言,有很多open source可以使用。

CAPTCHA

Python 

  • PyCaptcha Python语言实现的CAPTCHA库
  • Python Module at CAPTCHAs.net are providing a python module to simplify the task of writing a web application usingCAPTCHAs.net.

Java 

  • The JCAPTCHA Project, java实现的Captcha库
  • The reCAPTCHA Project, Java实现的库
  • The simple CAPTCHA Project, a new open-source Java implementation.
  • Proposal and source code for an audio based CAPTCHA written in Java.

PHP 

  • VeriWord, PHP
  • Image Verification Tutorial, PHP + GD(Planet Source Code)
  • Image Verification, PHP + GD
  • Auditor, PHP + GD
  • Forms generation and validation class with a plug-in to implement a CAPTCHA validation input
  • PEAR's Text_CAPTCHA, a PHP implementation.
  • tEABAG_3D CAPTCHA, by OCR Research Team. 3D captchas using PHP4 + GD.
  • Block AutoSubmit, Implementation that works with newer and older GD down to version 1.63.
  • KCAPTCHA, PHP + GD, text-distortion.

Perl 

  • Authen::CAPTCHA,Perl
  • GD::SecurityImage, Perl(GD + Image::Magick).

Classic ASP 

  • Poor man's CAPTCHA, aClassic ASP implementation using CSS, javascript and ASP.

.NET 

  • CAPTCHA Image,.NET(ASP.NET用)
  • CAPTCHA Custom Control, ASP.NET的CAPTCHA服务器控制板

Ruby 

  • Ruby/CAPTCHA, Ruby和GD的Ruby实现的库

Smalltalk 

  • SW2Captcha, aSmalltalk implementation using Morphic.

CAPTCHA服务

  • CAPTCHA Service Free service, supports reload button, audio and smart captcha technology.
  • captcha.jp , 日语版的CAPTCHA服务
  • captchas.net, Free CAPTCHA Service (image and audio)
  • address-protector.com, A way to avoid email spam; you give it your email address, it gives you a link which when clicked will show a captcha which when 'passed' will show your email address.

使用例子:

Here are the details of how to integrate Kaptcha into your own application.

  • Put the appropriate .jar file (depending on which JDK you are using) into the WEB-INF/lib directory of your .war file.
  • Put the image tag into your page (checking that the path to the .jpg matches up with what is defined in your web.xml below for the url-pattern):

<form action="submit.action">    <img src="kaptcha.jpg" /> <input type="text" name="kaptcha" value="" /></form>

  • Put the reference in your web.xml (checking that the url-pattern path matches up with what you put in your html fragment above):

<servlet>        <servlet-name>Kaptcha</servlet-name>        <servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class></servlet><servlet-mapping>        <servlet-name>Kaptcha</servlet-name>        <url-pattern>/kaptcha.jpg</url-pattern></servlet-mapping>

  • In your code that manages the submit action:

String kaptchaExpected = (String)request.getSession()    .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);String kaptchaReceived = request.getParameter("kaptcha");if (kaptchaReceived == null || !kaptchaReceived.equalsIgnoreCase(kaptchaExpected)){    setError("kaptcha", "Invalid validation code.");}

  • Make sure to start your JDK with -Djava.awt.headless=true


原创粉丝点击