No description or website provided.
Switch branches/tags
Nothing to show
Clone or download
Latest commit a00bbb6 Oct 17, 2018

README.md

Blade-Patchca: verification code library for Java

Overview

Simple yet powerful verification code library written in Java with zero dependency.

You can generate verification code picture like this:

sample

Steps to Integrate

  • Add following dependency in your pom.xml
<dependency>
    <groupId>com.bladejava</groupId>
    <artifactId>blade-patchca</artifactId>
    <version>1.1.2</version>
</dependency>
  • Add following dependency in your code
ConfigurableCaptchaService cs = new ConfigurableCaptchaService();
cs.setColorFactory(new SingleColorFactory(new Color(25, 60, 170)));
cs.setFilterFactory(new CurvesRippleFilterFactory(cs.getColorFactory()));

FileOutputStream fos = new FileOutputStream("demo.png");
String challenge = EncoderHelper.getChallangeAndWriteImage(cs, "png", fos);
//Challenge text needs to be kept in the session for verification 
fos.close();
  • Use following code to create differnt types of captcha
switch (new Random().nextInt(5)) {
			case 0:
				cs.setFilterFactory(new CurvesRippleFilterFactory(cs.getColorFactory()));
				break;
			case 1:
				cs.setFilterFactory(new MarbleRippleFilterFactory());
				break;
			case 2:
				cs.setFilterFactory(new DoubleRippleFilterFactory());
				break;
			case 3:
				cs.setFilterFactory(new WobbleRippleFilterFactory());
				break;
			case 4:
				cs.setFilterFactory(new DiffuseRippleFilterFactory());
				break;
}