captcha

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpired = errors.New("Expired")
	ErrInvalid = errors.New("Invalid")
)

Functions

func Check

func Check(id, code string) (bool, error)

Check 验证验证码是否正确,返回错误类型

func CheckOk

func CheckOk(id, code string) bool

Check 验证验证码是否正确

func Create

func Create() (id, result string, img image.Image)

Create 创建验证码,返回图片对象image.Image

func CreateB64

func CreateB64() (id, result string, data string, err error)

CreateB64 创建验证码,返回图片base64

func CreateBytes

func CreateBytes() (id, result string, buf []byte, err error)

CreateBytes 创建验证码,返回图片数据[]byte

Types

type Captcha

type Captcha struct {
	*Config
	// contains filtered or unexported fields
}

func New

func New(c *Config) (*Captcha, error)

func (*Captcha) Draw

func (c *Captcha) Draw() (image.Image, *Data)

type Config

type Config struct {
	Width, Height                    int         // width and height of the captcha image
	Bg, Ft                           color.Color // background and font color
	Face                             font.Face   // font face
	Size                             float64     // font size
	DPI                              float64     // DPI
	Lines, Points, Rotates, Distorts int         // Number of
	Bit                              int         // Length of captcha text
}

func (*Config) ParseFont

func (c *Config) ParseFont(buf []byte) error

func (*Config) Validate

func (c *Config) Validate() error

type Data

type Data struct {
	Content string
	Result  string
	Expire  int64
}

Jump to

Keyboard shortcuts

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