Giter Club home page Giter Club logo

xvcode's Introduction

xvcode (x-validation code)

project description:

this project only for web validation code generating. we provide this tool cause there no security enough validation-code-image generator. this tool provide 4 kind of valid-code image generators. as follows:

this project refer the gifencoder

项目作用: 主要用于生成web动态验证码图片。主要应用场景为web 页面上需要用户输入验证码才能进行操作的地方。 开发原因: 目前网络广为流传的代码所生成的验证码图片太简单,并易于破解。所以我们自己开发了一个简单的验证码生成包,增加了背景的干扰性。 features:

  • 提供1中png格式的图片生成器,3种gif格式图片生成器。
  • 随机码由生成器自身生成。
  • 可一定程度自定义背景干扰图形参数

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

图片示例 mapping from generator to image style

PngVCGenerator: Png

GifVCGenerator: Gif1

GifVCGenerator2: Gif1

GifVCGenerator3: Gif1

Getting Started

For Java Developers

Add Dependency(maven)

add dependency to your pom.xml:

<dependency>
	<groupId>com.github.botaruibo</groupId>
	<artifactId>xvcode</artifactId>
	<version>1.0</version>
</dependency>

####### Code Examples

package test

import java.io.FileOutputStream;
import java.io.IOException;
import com.github.botaruibo.xvcode.generator.Generator;
import com.github.botaruibo.xvcode.generator.Gif2VCGenerator;
import com.github.botaruibo.xvcode.generator.Gif3VCGenerator;
import com.github.botaruibo.xvcode.generator.GifVCGenerator;
import com.github.botaruibo.xvcode.generator.PngVCGenerator;

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);
}
}

the generator.write2out() method proved the ability to write the image binary to any OutputStream object. this especially convenience for servlet request

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

Use Under Command(require ${JAVA_HOME} set)

use the xvcode-1.0-SNAPSHOT-cl.jar file to generate valid-code image directly to disk. command like:

可以使用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
	

example:

例如:

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

xvcode's People

Contributors

botaruibo avatar

Watchers

James Cloos avatar weixiao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.