mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-27 13:03:12 -05:00
made changes to checkCaptcha function
This commit is contained in:
parent
a4a3a63f3f
commit
0fe1dd1ae4
@ -25,7 +25,7 @@ public class FontFunCaptcha implements ChallengeProvider{
|
||||
FontMetrics fontMetrics = graphics2D.getFontMetrics();
|
||||
HelperFunctions.setRenderingHints(graphics2D);
|
||||
graphics2D.setColor(Color.decode(colors[rand.nextInt(4)]));
|
||||
graphics2D.drawString(String.valueOf(captchaText.toLowerCase().charAt(i)), (i * 48), fontMetrics.getAscent());
|
||||
graphics2D.drawString(String.valueOf(captchaText.charAt(i)), (i * 48), fontMetrics.getAscent());
|
||||
}
|
||||
graphics2D.dispose();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
@ -39,10 +39,10 @@ public class FontFunCaptcha implements ChallengeProvider{
|
||||
|
||||
public Challenge returnChallenge() {
|
||||
String secret = HelperFunctions.randomString(7);
|
||||
return new Challenge(fontFun(secret),"png",secret);
|
||||
return new Challenge(fontFun(secret),"png",secret.toLowerCase());
|
||||
}
|
||||
|
||||
public boolean checkAnswer(String secret, String answer){
|
||||
return secret.equals(answer);
|
||||
return answer.toLowerCase().equals(secret);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class GifCaptcha implements ChallengeProvider{
|
||||
return img;
|
||||
}
|
||||
|
||||
public byte[] gifCaptcha(String text){
|
||||
private byte[] gifCaptcha(String text){
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
ImageOutputStream output = new MemoryCacheImageOutputStream(byteArrayOutputStream);
|
||||
@ -42,11 +42,11 @@ public class GifCaptcha implements ChallengeProvider{
|
||||
|
||||
public Challenge returnChallenge() {
|
||||
String secret = HelperFunctions.randomString(6);
|
||||
return new Challenge(gifCaptcha(secret),"gif",secret);
|
||||
return new Challenge(gifCaptcha(secret),"gif",secret.toLowerCase());
|
||||
}
|
||||
|
||||
public boolean checkAnswer(String secret, String answer) {
|
||||
return secret.equals(answer);
|
||||
return answer.toLowerCase().equals(secret);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -12,7 +12,7 @@ public class HelperFunctions {
|
||||
}
|
||||
|
||||
public static String randomString(int n){
|
||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
|
||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz23456789$#%@&?";
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for(int i=0; i<n; i++){
|
||||
int index = (int)(characters.length() * Math.random());
|
||||
|
@ -17,10 +17,10 @@ public class ShadowTextCaptcha implements ChallengeProvider{
|
||||
}
|
||||
|
||||
public boolean checkAnswer(String secret, String answer) {
|
||||
return secret.equals(answer);
|
||||
return answer.toLowerCase().equals(secret);
|
||||
}
|
||||
|
||||
public byte[] shadowText(String text){
|
||||
private byte[] shadowText(String text){
|
||||
BufferedImage img = new BufferedImage(350, 100, BufferedImage.TYPE_INT_RGB);
|
||||
Font font = new Font("Arial",Font.ROMAN_BASELINE ,48);
|
||||
Graphics2D graphics2D = img.createGraphics();
|
||||
@ -55,6 +55,6 @@ public class ShadowTextCaptcha implements ChallengeProvider{
|
||||
|
||||
public Challenge returnChallenge() {
|
||||
String secret = HelperFunctions.randomString(6);
|
||||
return new Challenge(shadowText(secret),"png",secret);
|
||||
return new Challenge(shadowText(secret),"png",secret.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user