captcha

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package captcha draws the image captchas of the captcha challenge with the standard library only: a built-in 5x7 dot-matrix font, randomly placed, scaled, rotated and sheared characters on a wavy baseline, with noise lines and dots, encoded as a small paletted PNG.

The agent generates a pool every few minutes and hands it to the data plane (PUT /v1/challenge/captchas); the answers never leave the node.

Index

Constants

View Source
const (
	// Length is the number of characters of an answer.
	Length = 5
	// Width and Height are the image size in pixels.
	Width  = 160
	Height = 60
)
View Source
const Alphabet = "ABCDEFGHJKMNPQRSTUVWXYZ23456789"

Alphabet leaves out characters that are easy to confuse (0/O, 1/I/L).

Variables

This section is empty.

Functions

func Answer

func Answer(r io.Reader) (string, error)

Answer returns a random answer read from r.

func Draw

func Draw(r io.Reader, answer string) ([]byte, error)

Draw renders answer (characters of Alphabet) as a PNG; the geometry comes from a ChaCha8 stream seeded from r (crypto/rand.Reader when nil).

Types

type Image

type Image struct {
	Answer string
	PNG    []byte
}

Image is one captcha: its answer and the PNG.

func New

func New(r io.Reader) (Image, error)

New draws a captcha for a random answer; r supplies the randomness (crypto/rand.Reader when nil).

func Pool

func Pool(r io.Reader, n int) ([]Image, error)

Pool draws n captchas with distinct answers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL