Class Base64CaptchaRenderer

java.lang.Object
cloud.opencode.base.captcha.renderer.Base64CaptchaRenderer
All Implemented Interfaces:
CaptchaRenderer

public final class Base64CaptchaRenderer extends Object implements CaptchaRenderer
Base64 Captcha Renderer - Renders CAPTCHA as Base64 data URL Base64 验证码渲染器 - 将验证码渲染为 Base64 数据 URL

Features | 主要功能:

  • Base64 data URL output - Base64数据URL输出
  • Embeddable in HTML - 可嵌入HTML

Usage Examples | 使用示例:

CaptchaRenderer renderer = new Base64CaptchaRenderer();
renderer.render(captcha, outputStream);

Security | 安全性:

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

    • Base64CaptchaRenderer

      public Base64CaptchaRenderer()
  • Method Details

    • render

      public void render(Captcha captcha, OutputStream out) throws IOException
      Description copied from interface: CaptchaRenderer
      Renders the CAPTCHA to an output stream. 将验证码渲染到输出流。
      Specified by:
      render in interface CaptchaRenderer
      Parameters:
      captcha - the CAPTCHA | 验证码
      out - the output stream | 输出流
      Throws:
      IOException - if rendering fails | 如果渲染失败
    • renderToBytes

      public byte[] renderToBytes(Captcha captcha)
      Description copied from interface: CaptchaRenderer
      Renders the CAPTCHA to a byte array. 将验证码渲染到字节数组。
      Specified by:
      renderToBytes in interface CaptchaRenderer
      Parameters:
      captcha - the CAPTCHA | 验证码
      Returns:
      the rendered bytes | 渲染的字节
    • renderToBase64

      public String renderToBase64(Captcha captcha)
      Description copied from interface: CaptchaRenderer
      Renders the CAPTCHA to a Base64 string. 将验证码渲染到 Base64 字符串。
      Specified by:
      renderToBase64 in interface CaptchaRenderer
      Parameters:
      captcha - the CAPTCHA | 验证码
      Returns:
      the Base64 string | Base64 字符串
    • getContentType

      public String getContentType()
      Description copied from interface: CaptchaRenderer
      Gets the content type of the rendered output. 获取渲染输出的内容类型。
      Specified by:
      getContentType in interface CaptchaRenderer
      Returns:
      the content type | 内容类型