CAPTCHA Generation and Verification
Latest stable Based on Image release 0.3.0
bluetape4k-images-captcha separates image generation from challenge storage and one-shot verification. This boundary matters: drawing text is only one part of a usable CAPTCHA flow.
Generation
Section titled “Generation”CaptchaGenerator produces a CaptchaChallenge from CaptchaOptions. Options cover image size, fonts, colors, noise, distortion, and answer characteristics. Validate ranges before accepting product or tenant configuration; extreme dimensions, font sizes, or noise counts can create unusable images or expensive work.
Java2D generation runs headless in tests and servers. The result uses the core immutable image model, so normal image writers can encode the challenge.
Verification lifecycle
Section titled “Verification lifecycle”CaptchaChallengeStore owns challenge state. CaptchaVerificationService distinguishes success from wrong answer, expiry, and missing challenge. Verification is one-shot: design the store operation so two concurrent requests cannot both consume the same challenge.
Do not store or log the plaintext answer longer than required. Bind a challenge to the relevant session or transaction, expire it promptly, rate-limit issue and verify routes, and return a generic client failure that does not reveal whether an identifier exists.
Framework path
Section titled “Framework path”Ktor integration supplies issue and verify route helpers. The Ktor image API workshop shows the full lifecycle. Other frameworks can use the generator, store, and service directly.