mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-27 13:03:12 -05:00
debug catpcha: only use alphabets
Signed-off-by: hrj <harshad.rj@gmail.com>
This commit is contained in:
parent
332bb2113b
commit
954399042c
@ -11,9 +11,17 @@ public class HelperFunctions {
|
||||
RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
}
|
||||
|
||||
public static String randomString(int n) {
|
||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz23456789$#%@&?";
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
public static final String alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
public static final String numbers = "23456789";
|
||||
public static final String specialCharacters = "$#%@&?";
|
||||
public static final String allCharacters = alphabets + numbers + specialCharacters;
|
||||
|
||||
public static String randomString(final int n) {
|
||||
return randomString(n, allCharacters);
|
||||
}
|
||||
|
||||
public static String randomString(final int n, final String characters) {
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < n; i++) {
|
||||
int index = (int) (characters.length() * Math.random());
|
||||
stringBuilder.append(characters.charAt(index));
|
||||
|
@ -58,7 +58,7 @@ class DebugCaptcha extends ChallengeProvider {
|
||||
}
|
||||
|
||||
def returnChallenge(): Challenge = {
|
||||
val secret = HelperFunctions.randomString(6)
|
||||
val secret = HelperFunctions.randomString(6, HelperFunctions.alphabets)
|
||||
new Challenge(simpleText(secret), "image/png", secret.toLowerCase())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user