验证码类
import lombok.Data;
@Data
public class VerifyCode {
private String code;
private byte[] imgBytes;
private long expireTime;
}
验证码接口
import java.io.IOException;
import java.io.OutputStream;
public interface IVerifyCodeGen {
String generate(int width, int height, OutputStream os) throws IOException;
VerifyCode generate(int width, int height) throws IOException;
}
验证码内容生成类
import java.awt.*;
import java.util.Random;
public class RandomUtils {
private static final char[] CODE_SEQ = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J',
'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', '8', '9' };
private static final char[] NUMBER_ARRAY = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
private static Random random = new Random();
public static String randomString(int length) {
StringBuilder</