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.

30 lines
1.2 KiB

4 weeks ago
  1. // com.example.demo.config.KaptchaConfig.java
  2. package com.example.demo.config;
  3. import com.google.code.kaptcha.impl.DefaultKaptcha;
  4. import com.google.code.kaptcha.util.Config;
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.context.annotation.Configuration;
  7. import java.util.Properties;
  8. @Configuration
  9. public class KaptchaConfig {
  10. @Bean
  11. public DefaultKaptcha defaultKaptcha() {
  12. DefaultKaptcha kaptcha = new DefaultKaptcha();
  13. Properties properties = new Properties();
  14. properties.setProperty("kaptcha.image.width", "130");
  15. properties.setProperty("kaptcha.image.height", "45");
  16. properties.setProperty("kaptcha.textproducer.char.length", "4");
  17. properties.setProperty("kaptcha.textproducer.font.size", "35");
  18. properties.setProperty("kaptcha.textproducer.font.color", "black");
  19. properties.setProperty("kaptcha.textproducer.char.space", "5");
  20. properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.WaterRipple");
  21. properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.DefaultNoise");
  22. kaptcha.setConfig(new Config(properties));
  23. return kaptcha;
  24. }
  25. }