Class AudioCaptchaGenerator
java.lang.Object
cloud.opencode.base.captcha.generator.AbstractCaptchaGenerator
cloud.opencode.base.captcha.generator.AudioCaptchaGenerator
- All Implemented Interfaces:
CaptchaGenerator
public final class AudioCaptchaGenerator
extends AbstractCaptchaGenerator
implements CaptchaGenerator
Audio Captcha Generator - Generates audio CAPTCHA challenges as WAV files
音频验证码生成器 - 生成 WAV 格式的音频验证码挑战
This generator creates audio CAPTCHAs by synthesizing unique tone sequences for each character in the verification code. The generated audio includes background noise and interference tones to prevent automated recognition.
此生成器通过为验证码中的每个字符合成独特的音调序列来创建音频验证码。 生成的音频包含背景噪声和干扰音调以防止自动识别。
Features | 主要功能:
- 16kHz 16-bit mono PCM WAV output - 16kHz 16位单声道 PCM WAV 输出
- Unique tone sequences per character - 每个字符独特的音调序列
- Background white noise (~15dB SNR) - 背景白噪声(约15dB信噪比)
- Random interference tones - 随机干扰音调
- Variable speed and frequency offsets - 可变速度和频率偏移
Usage Examples | 使用示例:
AudioCaptchaGenerator generator = new AudioCaptchaGenerator();
Captcha captcha = generator.generate(CaptchaConfig.builder()
.length(4)
.audioSpeedVariation(0.2f)
.build());
byte[] wavData = captcha.imageData();
Security | 安全性:
- Thread-safe: Yes (stateless, uses local SecureRandom) - 线程安全: 是(无状态,使用局部 SecureRandom)
- Null-safe: No (config must not be null) - 空值安全: 否(config 不能为空)
- Since:
- JDK 25, opencode-base-captcha V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
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
-
AudioCaptchaGenerator
public AudioCaptchaGenerator()
-
-
Method Details
-
getType
Description copied from interface:CaptchaGeneratorGets the supported CAPTCHA type. 获取支持的验证码类型。- Specified by:
getTypein interfaceCaptchaGenerator- Returns:
- the CAPTCHA type | 验证码类型
-
generate
Description copied from interface:CaptchaGeneratorGenerates a CAPTCHA with the specified configuration. 使用指定配置生成验证码。- Specified by:
generatein interfaceCaptchaGenerator- Parameters:
config- the configuration | 配置- Returns:
- the generated CAPTCHA | 生成的验证码
-