You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
618 B
26 lines
618 B
package org.ros.chatto.service;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import org.ros.chatto.captcha.SimpleCaptchaBehavior;
|
|
import org.ros.chatto.captcha.WebCaptcha;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@Service
|
|
public class CaptchaService {
|
|
private final WebCaptcha webCaptcha;
|
|
|
|
public CaptchaService() {
|
|
webCaptcha = WebCaptcha.builder().captchaBehaviour(new SimpleCaptchaBehavior()).build();
|
|
}
|
|
|
|
public BufferedImage createCaptchaImage(final String captchaText)
|
|
{
|
|
return webCaptcha.generateCaptcha(captchaText);
|
|
}
|
|
|
|
public String getRandomText()
|
|
{
|
|
return webCaptcha.getRandomChars();
|
|
}
|
|
}
|