Skip to content

feat: Captcha v2 — verifiable keys, new types, audio, and CI - #1

Merged
ErfanMomeniii merged 5 commits into
masterfrom
feat/captcha-v2
Jul 24, 2026
Merged

ErfanMomeniii merged 5 commits into
masterfrom
feat/captcha-v2

Conversation

@ErfanMomeniii

@ErfanMomeniii ErfanMomeniii commented Jul 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Captcha v2. The core change: every generator now returns a *Result carrying the answer (Result.Text) alongside the image, so captchas are actually verifiable — previously only the image came back. Adds new captcha types, an audio captcha, a noise/distortion system, a friendlier API, and CI.

Module path moves to .../captcha/v2 (breaking).

What's new

  • Verifiable keys — Result{Text, Image} from all image generators.
  • New types — Custom (your charset), Word (from a list), Math (arithmetic), and a standalone AudioCaptcha (dependency-free WAV).
  • Bot resistance — four Noise levels (per-char jitter, dots, lines).
  • Ergonomics — zero-config package one-liners (captcha.Numeric(6)), sensible defaults + WithSize/WithFontSize,
    Result.PNG()/WriteTo()/DataURI(), and captcha.Match()
  • Under the hood — font parsed once and cached; input validation; crypto-strong keys (crypto/rand).
  • CI — GitHub Actions: gofmt/vet/golangci-lint, -race tests across Go 1.26 + stable on Linux/macOS/Windows, build.

Breaking changes

  • Import path is now github.com/ErfanMomeniii/captcha/v2.
  • Generators return (*Result, error) instead of (image.Image, error).
  • New is option-based: New(opts ...Option) — use WithSize/WithFontSize for dimensions.
// before
im, _ := c.Numeric(6)
// after 
r, _ := c.Numeric(6) // r.Text = answer, r.Image = picture

Testing

go build ./..., go vet ./..., golangci-lint run (0 issues), and go test -race ./... all pass (~95% coverage on the library). Example runs end-to-end.

@ErfanMomeniii
ErfanMomeniii merged commit 0b34b34 into master Jul 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant