Use char[] for captcha generation.

This commit is contained in:
asofold 2012-10-01 02:59:02 +02:00
parent 983c7173d7
commit 13c4d654db

View File

@ -61,10 +61,11 @@ public class Captcha extends AsyncCheck implements ICaptcha{
@Override @Override
public void generateCaptcha(ChatConfig cc, ChatData data, boolean reset) { public void generateCaptcha(ChatConfig cc, ChatData data, boolean reset) {
if (reset) data.captchTries = 0; if (reset) data.captchTries = 0;
data.captchaGenerated = ""; final char[] chars = new char[cc.captchaLength];
for (int i = 0; i < cc.captchaLength; i++) for (int i = 0; i < cc.captchaLength; i++)
data.captchaGenerated += cc.captchaCharacters.charAt(random chars[i] = cc.captchaCharacters.charAt(random
.nextInt(cc.captchaCharacters.length())); .nextInt(cc.captchaCharacters.length()));
data.captchaGenerated = new String(chars);
} }
@Override @Override