Class AudioCaptchaRenderer
java.lang.Object
cloud.opencode.base.captcha.renderer.AudioCaptchaRenderer
- All Implemented Interfaces:
CaptchaRenderer
Audio Captcha Renderer - Renders CAPTCHA as WAV audio
音频验证码渲染器 - 将验证码渲染为 WAV 音频
This renderer outputs the pre-generated WAV audio data from the CAPTCHA.
The audio data is stored in the imageData field of the Captcha record.
此渲染器输出验证码中预生成的 WAV 音频数据。
音频数据存储在 Captcha 记录的 imageData 字段中。
Features | 主要功能:
- WAV audio output - WAV 音频输出
- Stream-based rendering - 基于流的渲染
- Base64 encoding support - Base64 编码支持
Usage Examples | 使用示例:
CaptchaRenderer renderer = new AudioCaptchaRenderer();
renderer.render(captcha, outputStream);
String base64 = renderer.renderToBase64(captcha);
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
- Null-safe: No (captcha and stream must not be null) - 空值安全: 否(验证码和流不能为null)
- Since:
- JDK 25, opencode-base-captcha V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the content type of the rendered output.voidrender(Captcha captcha, OutputStream out) Renders the CAPTCHA to an output stream.renderToBase64(Captcha captcha) Renders the CAPTCHA to a Base64 string.byte[]renderToBytes(Captcha captcha) Renders the CAPTCHA to a byte array.
-
Constructor Details
-
AudioCaptchaRenderer
public AudioCaptchaRenderer()
-
-
Method Details
-
render
Description copied from interface:CaptchaRendererRenders the CAPTCHA to an output stream. 将验证码渲染到输出流。- Specified by:
renderin interfaceCaptchaRenderer- Parameters:
captcha- the CAPTCHA | 验证码out- the output stream | 输出流- Throws:
IOException- if rendering fails | 如果渲染失败
-
renderToBytes
Description copied from interface:CaptchaRendererRenders the CAPTCHA to a byte array. 将验证码渲染到字节数组。- Specified by:
renderToBytesin interfaceCaptchaRenderer- Parameters:
captcha- the CAPTCHA | 验证码- Returns:
- the rendered bytes | 渲染的字节
-
renderToBase64
Description copied from interface:CaptchaRendererRenders the CAPTCHA to a Base64 string. 将验证码渲染到 Base64 字符串。- Specified by:
renderToBase64in interfaceCaptchaRenderer- Parameters:
captcha- the CAPTCHA | 验证码- Returns:
- the Base64 string | Base64 字符串
-
getContentType
Description copied from interface:CaptchaRendererGets the content type of the rendered output. 获取渲染输出的内容类型。- Specified by:
getContentTypein interfaceCaptchaRenderer- Returns:
- the content type | 内容类型
-