Class ImageCaptchaGenerator
java.lang.Object
cloud.opencode.base.captcha.generator.AbstractCaptchaGenerator
cloud.opencode.base.captcha.generator.ImageCaptchaGenerator
- All Implemented Interfaces:
CaptchaGenerator
public final class ImageCaptchaGenerator
extends AbstractCaptchaGenerator
implements CaptchaGenerator
Image Captcha Generator - Generates static image CAPTCHA
图像验证码生成器 - 生成静态图像验证码
This generator creates standard image-based CAPTCHAs with text.
此生成器创建带文本的标准图像验证码。
Features | 主要功能:
- Static image CAPTCHA generation - 静态图像验证码生成
- Multiple type support (alphanumeric, numeric, alpha) - 多种类型支持(字母数字、纯数字、纯字母)
- Random font per character for anti-OCR - 每字符随机字体抗OCR
- Character overlap for anti-segmentation - 字符重叠抗分割
- Outline shadow for anti-OCR - 轮廓阴影抗OCR
- Bezier noise through character area - 贝塞尔穿字噪声
- Sine wave warp distortion - 正弦波变形扭曲
Usage Examples | 使用示例:
CaptchaGenerator gen = new ImageCaptchaGenerator(CaptchaType.ALPHANUMERIC);
Captcha captcha = gen.generate(config);
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
- 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 Summary
ConstructorsConstructorDescriptionCreates a new generator with the specified type. -
Method Summary
Modifier and TypeMethodDescriptiongenerate(CaptchaConfig config) Generates a CAPTCHA with the specified configuration.getType()Gets the supported CAPTCHA type.Methods inherited from class AbstractCaptchaGenerator
buildCaptcha, createGraphics, createImage, createMetadata, drawNoise, generateId, toBytesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CaptchaGenerator
generate
-
Constructor Details
-
ImageCaptchaGenerator
Creates a new generator with the specified type. 使用指定类型创建新生成器。- Parameters:
type- the CAPTCHA type | 验证码类型
-
-
Method Details
-
generate
Description copied from interface:CaptchaGeneratorGenerates a CAPTCHA with the specified configuration. 使用指定配置生成验证码。- Specified by:
generatein interfaceCaptchaGenerator- Parameters:
config- the configuration | 配置- Returns:
- the generated CAPTCHA | 生成的验证码
-
getType
Description copied from interface:CaptchaGeneratorGets the supported CAPTCHA type. 获取支持的验证码类型。- Specified by:
getTypein interfaceCaptchaGenerator- Returns:
- the CAPTCHA type | 验证码类型
-