public class VerifyCodeTools extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private static Random |
random |
static String |
VERIFY_CODES |
| 构造器和说明 |
|---|
VerifyCodeTools() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
generateVerifyCode(int verifySize)
使用系统默认字符源生成验证码
|
static String |
generateVerifyCode(int verifySize,
String sources)
使用指定源生成验证码
|
private static Color |
getRandColor(int fc,
int bc) |
private static int |
getRandomIntColor() |
private static int[] |
getRandomRgb() |
static void |
main(String[] args) |
static String |
outputBase64(int w,
int h,
String code,
String imageType) |
static void |
outputImage(int w,
int h,
File outputFile,
String code,
String imageType)
生成指定验证码图像文件
|
static void |
outputImage(int w,
int h,
OutputStream os,
String code,
String imageType)
输出指定验证码图片流
|
static String |
outputVerifyImage(int w,
int h,
File outputFile,
int verifySize,
String imageType)
生成随机验证码文件,并返回验证码值
|
static String |
outputVerifyImage(int w,
int h,
OutputStream os,
int verifySize,
String imageType)
输出随机验证码图片流,并返回验证码值
|
private static void |
shear(Graphics g,
int w1,
int h1,
Color color) |
private static void |
shearX(Graphics g,
int w1,
int h1,
Color color) |
private static void |
shearY(Graphics g,
int w1,
int h1,
Color color) |
private static Random random
public static String generateVerifyCode(int verifySize)
verifySize - 验证码长度public static String generateVerifyCode(int verifySize, String sources)
verifySize - 验证码长度sources - 验证码字符源public static String outputVerifyImage(int w, int h, File outputFile, int verifySize, String imageType) throws IOException
w - h - outputFile - verifySize - IOExceptionpublic static String outputVerifyImage(int w, int h, OutputStream os, int verifySize, String imageType) throws IOException
w - h - os - verifySize - IOExceptionpublic static void outputImage(int w,
int h,
File outputFile,
String code,
String imageType)
throws IOException
w - h - outputFile - code - IOExceptionpublic static void outputImage(int w,
int h,
OutputStream os,
String code,
String imageType)
throws IOException
w - h - os - code - IOExceptionpublic static String outputBase64(int w, int h, String code, String imageType) throws IOException
IOExceptionprivate static Color getRandColor(int fc, int bc)
private static int getRandomIntColor()
private static int[] getRandomRgb()
public static void main(String[] args) throws IOException
IOExceptionCopyright © 2022. All rights reserved.