captcha
easy-captcha是生成图形验证码的Java类库,支持gif、中文、算术等类型,可用于Java Web、JavaSE等项目。参考地址:https://gitee.com/whvse/EasyCaptcha
maven坐标:
1 2 3 4 5 6 7 8 9 10 11
| <dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId>
<version>1.6.2</version>
</dependency>
|
效果展示:

使用方式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| package com.itheima.pinda;
import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.base.Captcha;
import java.io.File;
import java.io.FileOutputStream;
publicclassEasyCaptchaTest {
publicstaticvoidmain(String[] args) throwsException{
Captchacaptcha = newArithmeticCaptcha(115, 42);
captcha.setCharType(2);
captcha.out(newFileOutputStream(newFile("d:\\hello.png")));
Stringtext = captcha.text();
System.out.println(text);
}
}
|