动态 Web 校验码图片生成 XVcode

码农软件 · 软件分类 · 验证码(Captcha) · 2019-04-22 09:43:49

软件介绍

XVcode,Web 动态验证码图片生成工具,用于生成随机验证码图片及返回验证码。以随机圆圈为干扰背景,增加随机前后景透明度,并提供3种gif动态图。

PngGenerator    :

GifGenerator:

Gif2Generator:

Gif3Generator:

该项目用于生成gif图片编码器使用了 gifencoder 项目

快速上手

class Test {
//生成验证码图片到本地磁盘 draw image and save to disk
public void main(String args[]) throws IOException {
        String path = ".";//图片存储路径 path for image save 
        Integer height = 40;//image 高度。  image height. count as pixel
        Integer width = 200;//image 宽度。 image width. count as pixel
        Integer count = 5;  // validation code length.
        String validCode = null; //验证码
        Generator generator = new PngVCGenerator(width, height, count);
        generator.write2out(new FileOutputStream(path + "/1.png")).close();
        validCode = generator.text(); //get the validation code as 'String'
        System.out.println(validCode);
        generator = new GifVCGenerator(width, height, count);//   gif
        generator.write2out(new FileOutputStream(path + "/1.gif")).close();
        validCode = generator.text();
        System.out.println(validCode);
        generator = new Gif2VCGenerator(width, height, count);//   gif
        generator.write2out(new FileOutputStream(path + "/2.gif")).close();
        validCode = generator.text();
        System.out.println(validCode);
        generator = new Gif3VCGenerator(width, height, count);//   gif
        generator.write2out(new FileOutputStream(path + "/3.gif")).close();
        validCode = generator.text();
        System.out.println(validCode);
}

如果要将验证码图片以流的方式传到前端,可以直接使用generator.write2out()方法

Use Under Command(require ${JAVA_HOME} set)

可以使用jar包直接生成本地图片。命令:

java -jar xvcode-1.0-SNAPSHOT-cl

usage :

支持参数如下:

usage:
    -p  dir path for the image, default generate in current dir
    -h  image height, between 50 to 500, default 200
    -w  image width, between 30 to 300, default 40
    -cl validation code length, between 2 to 10, default 5

示例:

java -jar xvcode-1.0-SNAPSHOT-cl -p test/ -h 300 -w 60 -cl 7

本文地址:https://www.codercto.com/soft/d/4123.html

Bandit Algorithms for Website Optimization

Bandit Algorithms for Website Optimization

John Myles White / O'Reilly Media / 2013-1-3 / USD 19.99

This book shows you how to run experiments on your website using A/B testing - and then takes you a huge step further by introducing you to bandit algorithms for website optimization. Author John Myle......一起来看看 《Bandit Algorithms for Website Optimization》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

MD5 加密
MD5 加密

MD5 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换