A self hosted chat application with end-to-end encrypted messaging.
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

  1. package org.ros.chatto.service;
  2. import java.awt.image.BufferedImage;
  3. import org.ros.chatto.captcha.SimpleCaptchaBehavior;
  4. import org.ros.chatto.captcha.WebCaptcha;
  5. import org.springframework.stereotype.Service;
  6. @Service
  7. public class CaptchaService {
  8. private final WebCaptcha webCaptcha;
  9. public CaptchaService() {
  10. webCaptcha = WebCaptcha.builder().captchaBehaviour(new SimpleCaptchaBehavior()).build();
  11. }
  12. public BufferedImage createCaptchaImage(final String captchaText)
  13. {
  14. return webCaptcha.generateCaptcha(captchaText);
  15. }
  16. public String getRandomText()
  17. {
  18. return webCaptcha.getRandomChars();
  19. }
  20. }