生成验证码的Java类库:Cage

jopen 6年前

Cage是一个用于生成验证码图的Java类库。它具有快速、小型和简单的特点。其目的是生成,易于人读取的图像,但对一台计算机不可能或至少是非常困难的读取。

生成验证码的Java类库:Cage 生成验证码的Java类库:Cage

特性

  • it is open source, Apache v2 licensed so it can be used in enterprise/proprietary projects too
  • it supports maven (available from the central maven repository)
  • it is fast (on the test pc 3-5 msec / image)
  • it is small (a single, small jar, no external dependencies, only Java 1.5 or newer is needed)
  • supports a wide variety of effects (symbol crowding, rotating, ripple - waving, outline shadowing and blurring)
  • has two predefined templates that mimics those captchas used by large email providers. See Templates for more info.
  • it is simple to use and integrate. See QuickStart for a fast start.

public class QuickStart {    public static void main(String[] args) throws IOException {      Cage cage = new GCage();        OutputStream os = new FileOutputStream("captcha.jpg", false);      try {        cage.draw(cage.getTokenGenerator().next(), os);      } finally {        os.close();      }    }  }

项目主页:http://www.open-open.com/lib/view/home/1397528578075