|
@@ -40,7 +40,16 @@ public class VerifyCode {
|
|
|
for (int i = 0; i < 500; i++) {
|
|
|
int x = random.nextInt(width);
|
|
|
int y = random.nextInt(height);
|
|
|
- graphics.drawOval(x, y, 0, 0);
|
|
|
+ graphics.drawOval(x, y, random.nextInt(2), random.nextInt(2));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成N条干扰线
|
|
|
+ for (int i = 0; i < 3; i++) {
|
|
|
+ int x1 = random.nextInt(width);
|
|
|
+ int y1 = random.nextInt(height);
|
|
|
+ int x2 = random.nextInt(width);
|
|
|
+ int y2 = random.nextInt(height);
|
|
|
+ graphics.drawLine(x1, y1, x2, y2);
|
|
|
}
|
|
|
|
|
|
// 随机生成三个数字、并组合成一个数学公式
|
|
@@ -124,11 +133,11 @@ public class VerifyCode {
|
|
|
final String imgPath = String.format("Img_%s.jpg", n);
|
|
|
File imgFile = new File(dir + "/" + imgPath);
|
|
|
ImageIO.write(result.getImage(), "JPEG", imgFile);
|
|
|
- System.out.println(result.getResult());
|
|
|
+ System.out.println(imgPath + " \t\t " + result.getResult());
|
|
|
|
|
|
byte[] bytes = imageToBytes(result.getImage());
|
|
|
String base64 = Base64Utils.encodeToString(bytes);
|
|
|
- System.out.println(base64 + "\n");
|
|
|
+ // System.out.println(base64 + "\n");
|
|
|
}
|
|
|
}*/
|
|
|
|