Class ArithmeticCaptchaGenerator

java.lang.Object
cloud.opencode.base.captcha.generator.AbstractCaptchaGenerator
cloud.opencode.base.captcha.generator.ArithmeticCaptchaGenerator
All Implemented Interfaces:
CaptchaGenerator

public final class ArithmeticCaptchaGenerator extends AbstractCaptchaGenerator implements CaptchaGenerator
Arithmetic Captcha Generator - Generates arithmetic expression CAPTCHA 算术验证码生成器 - 生成算术表达式验证码

This generator creates CAPTCHAs with mathematical expressions.

此生成器创建带数学表达式的验证码。

Features | 主要功能:

  • Arithmetic expression generation (add, subtract, multiply) - 算术表达式生成(加、减、乘)
  • Configurable difficulty - 可配置难度
  • Random font per character for anti-OCR - 每字符随机字体抗OCR
  • Outline shadow for anti-OCR - 轮廓阴影抗OCR
  • Bezier noise through character area - 贝塞尔穿字噪声
  • Sine wave warp distortion - 正弦波变形扭曲

Usage Examples | 使用示例:

CaptchaGenerator gen = new ArithmeticCaptchaGenerator();
Captcha captcha = gen.generate(config);

Security | 安全性:

  • Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
  • Null-safe: No (config must not be null) - 空值安全: 否(配置不能为null)
Since:
JDK 25, opencode-base-captcha V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • ArithmeticCaptchaGenerator

      public ArithmeticCaptchaGenerator()
  • Method Details

    • generate

      public Captcha generate(CaptchaConfig config)
      Description copied from interface: CaptchaGenerator
      Generates a CAPTCHA with the specified configuration. 使用指定配置生成验证码。
      Specified by:
      generate in interface CaptchaGenerator
      Parameters:
      config - the configuration | 配置
      Returns:
      the generated CAPTCHA | 生成的验证码
    • getType

      public CaptchaType getType()
      Description copied from interface: CaptchaGenerator
      Gets the supported CAPTCHA type. 获取支持的验证码类型。
      Specified by:
      getType in interface CaptchaGenerator
      Returns:
      the CAPTCHA type | 验证码类型