public class VerifyCode extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
TYPE_ALL_MIXED
验证码类型为数字、大写字母、小写字母混合
|
static int |
TYPE_LETTER_ONLY
验证码类型为仅字母,即大写、小写字母混合
|
static int |
TYPE_LOWER_ONLY
验证码类型为仅小写字母
|
static int |
TYPE_NUM_LOWER
验证码类型为数字、小写字母混合
|
static int |
TYPE_NUM_ONLY
验证码类型为仅数字 0~9
|
static int |
TYPE_NUM_UPPER
验证码类型为数字、大写字母混合
|
static int |
TYPE_UPPER_ONLY
验证码类型为仅大写字母
|
| 限定符和类型 | 方法和说明 |
|---|---|
static BufferedImage |
generateImageCode(int type,
int length,
String exChars,
int width,
int height,
int interLine,
boolean randomLocation,
Color backColor,
Color foreColor,
Color lineColor)
生成图片验证码
|
static BufferedImage |
generateImageCode(String textCode,
int width,
int height,
int interLine,
boolean randomLocation,
Color backColor,
Color foreColor,
Color lineColor)
已有验证码,生成验证码图片
|
static String |
generateTextCode(int type,
int length,
String exChars)
生成验证码字符串
|
static void |
main(String[] args) |
public static final int TYPE_NUM_ONLY
public static final int TYPE_LETTER_ONLY
public static final int TYPE_ALL_MIXED
public static final int TYPE_NUM_UPPER
public static final int TYPE_NUM_LOWER
public static final int TYPE_UPPER_ONLY
public static final int TYPE_LOWER_ONLY
public static String generateTextCode(int type, int length, String exChars)
type - 验证码类型,参见本类的静态属性length - 验证码长度,大于0的整数exChars - 需排除的特殊字符(仅对数字、字母混合型验证码有效,无需排除则为 null)public static BufferedImage generateImageCode(String textCode, int width, int height, int interLine, boolean randomLocation, Color backColor, Color foreColor, Color lineColor)
textCode - 文本验证码width - 图片宽度height - 图片高度interLine - 图片中干扰线的条数randomLocation - 每个字符的高低位置是否随机backColor - 图片颜色,若为null,则采用随机颜色foreColor - 字体颜色,若为null,则采用随机颜色lineColor - 干扰线颜色,若为null,则采用随机颜色public static BufferedImage generateImageCode(int type, int length, String exChars, int width, int height, int interLine, boolean randomLocation, Color backColor, Color foreColor, Color lineColor)
type - 验证码类型,参见本类的静态属性length - 验证码字符长度,大于0的整数exChars - 需排除的特殊字符width - 图片宽度height - 图片高度interLine - 图片中干扰线的条数randomLocation - 每个字符的高低位置是否随机backColor - 图片颜色,若为null,则采用随机颜色foreColor - 字体颜色,若为null,则采用随机颜色lineColor - 干扰线颜色,若为null,则采用随机颜色public static void main(String[] args)
Copyright © 2016. All rights reserved.