From b765399f68e5372bba141e04bb4f968790679bbf Mon Sep 17 00:00:00 2001 From: hrj Date: Tue, 13 Apr 2021 13:07:44 +0530 Subject: [PATCH] debug captcha: use safe alphabets only Signed-off-by: hrj --- src/main/java/lc/misc/HelperFunctions.java | 10 ++++++---- src/main/scala/lc/captchas/DebugCaptcha.scala | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/lc/misc/HelperFunctions.java b/src/main/java/lc/misc/HelperFunctions.java index 446d903..fa12fc8 100644 --- a/src/main/java/lc/misc/HelperFunctions.java +++ b/src/main/java/lc/misc/HelperFunctions.java @@ -11,13 +11,15 @@ public class HelperFunctions { RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); } - public static final String alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - public static final String numbers = "23456789"; + public static final String safeAlphabets = "ABCDEFGHJKMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + public static final String allAlphabets = safeAlphabets + "ILl"; + public static final String safeNumbers = "23456789"; + public static final String allNumbers = safeNumbers + "1"; public static final String specialCharacters = "$#%@&?"; - public static final String allCharacters = alphabets + numbers + specialCharacters; + public static final String safeCharacters = safeAlphabets + safeNumbers + specialCharacters; public static String randomString(final int n) { - return randomString(n, allCharacters); + return randomString(n, safeCharacters); } public static String randomString(final int n, final String characters) { diff --git a/src/main/scala/lc/captchas/DebugCaptcha.scala b/src/main/scala/lc/captchas/DebugCaptcha.scala index a2c4a62..084f1e1 100644 --- a/src/main/scala/lc/captchas/DebugCaptcha.scala +++ b/src/main/scala/lc/captchas/DebugCaptcha.scala @@ -58,7 +58,7 @@ class DebugCaptcha extends ChallengeProvider { } def returnChallenge(): Challenge = { - val secret = HelperFunctions.randomString(6, HelperFunctions.alphabets) + val secret = HelperFunctions.randomString(6, HelperFunctions.safeAlphabets) new Challenge(simpleText(secret), "image/png", secret.toLowerCase()) } }