CAPTCHA图片认证的一些资料

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

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

CAPTCHA

Python 
Java 
PHP 
Perl 
Classic ASP 
.NET 
Ruby 
Smalltalk 

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值