Cage 是一个 Java 实现的验证码图片生成库,快速、小型和简单。
示例代码:
1
2
3
4
5
6
7
8
9
10
11
12
|
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();
}
}
}
|
Maven:
1
2
3
4
5
|
<
dependency
>
<
groupId
>com.github.cage</
groupId
>
<
artifactId
>cage</
artifactId
>
<
version
>1.0</
version
>
</
dependency
>
|