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(); } }