From a61cfef88af2893e38c1abc2cb6b7fb14bd99253 Mon Sep 17 00:00:00 2001 From: shimingxy Date: Mon, 18 Nov 2024 16:08:22 +0800 Subject: [PATCH] kaptcha --- .../code/kaptcha/text/impl/RandomColorWordRenderer.java | 6 ++++-- .../{kaptcha_d.properties => kaptcha_default.properties} | 0 ...{kaptcha_c.properties => kaptcha_randomcolor.properties} | 0 3 files changed, 4 insertions(+), 2 deletions(-) rename maxkey-starter/maxkey-starter-captcha/src/main/resources/{kaptcha_d.properties => kaptcha_default.properties} (100%) rename maxkey-starter/maxkey-starter-captcha/src/main/resources/{kaptcha_c.properties => kaptcha_randomcolor.properties} (100%) diff --git a/maxkey-starter/maxkey-starter-captcha/src/main/java/com/google/code/kaptcha/text/impl/RandomColorWordRenderer.java b/maxkey-starter/maxkey-starter-captcha/src/main/java/com/google/code/kaptcha/text/impl/RandomColorWordRenderer.java index 74a2d3dfe..705f7714f 100644 --- a/maxkey-starter/maxkey-starter-captcha/src/main/java/com/google/code/kaptcha/text/impl/RandomColorWordRenderer.java +++ b/maxkey-starter/maxkey-starter-captcha/src/main/java/com/google/code/kaptcha/text/impl/RandomColorWordRenderer.java @@ -38,6 +38,9 @@ import com.google.code.kaptcha.util.Configurable; public class RandomColorWordRenderer extends Configurable implements WordRenderer { ConfigHelper configHelper = new ConfigHelper(); + + Random random = new SecureRandom(); + /** * Renders a word to an image. * @@ -69,8 +72,7 @@ public class RandomColorWordRenderer extends Configurable implements WordRendere g2D.setRenderingHints(hints); FontRenderContext frc = g2D.getFontRenderContext(); - Random random = new SecureRandom(); - + int startPosY = (height - fontSize) / 5 + fontSize; char[] wordChars = word.toCharArray(); diff --git a/maxkey-starter/maxkey-starter-captcha/src/main/resources/kaptcha_d.properties b/maxkey-starter/maxkey-starter-captcha/src/main/resources/kaptcha_default.properties similarity index 100% rename from maxkey-starter/maxkey-starter-captcha/src/main/resources/kaptcha_d.properties rename to maxkey-starter/maxkey-starter-captcha/src/main/resources/kaptcha_default.properties diff --git a/maxkey-starter/maxkey-starter-captcha/src/main/resources/kaptcha_c.properties b/maxkey-starter/maxkey-starter-captcha/src/main/resources/kaptcha_randomcolor.properties similarity index 100% rename from maxkey-starter/maxkey-starter-captcha/src/main/resources/kaptcha_c.properties rename to maxkey-starter/maxkey-starter-captcha/src/main/resources/kaptcha_randomcolor.properties