linghushaoxia / kaptcha

kaptcha验证码生成

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kaptcha


kaptcha验证码生成
验证码生成工具,生成浏览器可以识别的图片字符串
使用场景:
在网站任意需要验证码的位置,通过ajax向后台发请求,生成图片填充到image标签即可
使用方法:
public static void main(String[] args) {
//验证码的属性
Properties properties = new Properties();
//边框
properties.put("kaptcha.border", "yes");
//边框为绿色
properties.put("kaptcha.border.color", "green");
//图片宽度
properties.put("kaptcha.image.width", "200");
//高度
properties.put("kaptcha.image.height", "50");
//字符数量
properties.put("kaptcha.textproducer.char.length", "4");
//字体大小
properties.put("kaptcha.textproducer.font.size", "40");
//字符间隔
properties.put("kaptcha.textproducer.char.space", "2");
//噪声颜色
properties.put("kaptcha.noise.color", "black");
//粘贴到浏览器,可以查看浏览器中的显示效果
String[] validateCode= KaptchaServiceUtil.geneValidateCode(properties);
System.out.println(validateCode[1]);
System.out.println(validateCode[0]);
}
说明:
生成算法来自google公司的kaptcha,进行了封装。

About

kaptcha验证码生成


Languages

Language:Java 100.0%