captcha

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MIT Imports: 20 Imported by: 0

README

captcha

slide captcha

Documentation

Index

Constants

View Source
const (
	TypeSlide     = 1
	TypeWordsZhCn = 2
)
View Source
const (
	MimePng  = `image/png`
	MimeJpg  = `image/jpg`
	MimeJpeg = `image/jpeg`
)

Variables

View Source
var (
	// DefaultSlide default slide driver object
	DefaultSlide = NewSlide("", "", 70)
)
View Source
var (
	ErrFormat = errors.New("mime format unsupported")
)

Functions

This section is empty.

Types

type Captcha

type Captcha interface {
	Check(dots string, dct map[int]Dot, span int) bool
	Create() (dots map[int]Dot, b64 string, thumb64 string, key string, err error)
}

func NewWithOptions

func NewWithOptions(tp uint8, opts ...Option) Captcha

type Dot

type Dot struct {
	Index  int `json:"index,omitempty"`
	Dx     int `json:"dx,omitempty"`
	Dy     int `json:"dy,omitempty"`
	Width  int `json:"width,omitempty"`
	Height int `json:"height,omitempty"`
}

type Option

type Option func(opt *options)

func WithDriver

func WithDriver(driver *captcha.Captcha) Option

func WithQuality

func WithQuality(quality int) Option

func WithSlideBackDir

func WithSlideBackDir(backDir string) Option

func WithSlideMaskDir

func WithSlideMaskDir(maskDir string) Option

func WithWordsZhBackImgList

func WithWordsZhBackImgList(backImgList []string) Option

func WithWordsZhCnChars

func WithWordsZhCnChars(chars []string) Option

func WithWordsZhCnImgSize

func WithWordsZhCnImgSize(size captcha.Size) Option

func WithWordsZhCnThumbSize

func WithWordsZhCnThumbSize(size captcha.Size) Option

type Slide

type Slide struct {
	// contains filtered or unexported fields
}

Slide _

func NewSlide

func NewSlide(backDir, maskDir string, quality int) *Slide

NewSlide new slide with background and mask image list

func SlideWithBack

func SlideWithBack(backDir string) *Slide

SlideWithBack new slide with background image list

func SlideWithMask

func SlideWithMask(maskDir string) *Slide

SlideWithMask new slide with mask image list

func (*Slide) Check

func (s *Slide) Check(dots string, dct map[int]Dot, span int) bool

func (*Slide) Create

func (s *Slide) Create() (dots map[int]Dot, b64 string, thumb64 string, key string, err error)

Create generate slide key, x, y, and pictures.

func (*Slide) CreateCustom

func (s *Slide) CreateCustom(r, quality int) (dots map[int]Dot, b64 string, thumb64 string, key string, err error)

CreateCustom generate slide key, x, y, and pictures by custom.

This method is only used for custom background and masks images

func (*Slide) CreateShape

func (s *Slide) CreateShape(img *image.RGBA, point image.Point, r int) *image.RGBA

CreateShape create shape mask.

type WordsZhCn

type WordsZhCn struct {
	// contains filtered or unexported fields
}

func NewWordsZhCn

func NewWordsZhCn(driver *captcha.Captcha) *WordsZhCn

func (*WordsZhCn) Check

func (wzc *WordsZhCn) Check(dots string, dct map[int]Dot, span int) bool

func (*WordsZhCn) Create

func (wzc *WordsZhCn) Create() (dots map[int]Dot, b64 string, thumb64 string, key string, err error)

func (*WordsZhCn) Driver

func (wzc *WordsZhCn) Driver() *captcha.Captcha

Jump to

Keyboard shortcuts

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