captcha

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio struct {
	Language string
}

type Captcha

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

func New

func New(opts ...Option) *Captcha

func (*Captcha) Generate

func (c *Captcha) Generate() (key string, code string, err error)

func (*Captcha) Init

func (c *Captcha) Init() error

func (*Captcha) Provide

func (c *Captcha) Provide(ctx context.Context) interface{}

func (*Captcha) Verify

func (c *Captcha) Verify(key, answer string, clear bool) bool

type Option

type Option func(*Options)

func WithBgColor

func WithBgColor(bgColor string) Option

func WithCaptchaLen

func WithCaptchaLen(captchaLen int) Option

func WithCharacterCaptchaLen

func WithCharacterCaptchaLen(captchaLen int) Option

func WithEngine

func WithEngine(engine VerifyType) Option

func WithHeight

func WithHeight(height int) Option

func WithLanguage

func WithLanguage(language string) Option

func WithNoiseCount

func WithNoiseCount(noiseCount int) Option

func WithOptionShowHollowLine

func WithOptionShowHollowLine(showHollowLine bool) Option

func WithOptionShowSineLine

func WithOptionShowSineLine(showSineLine bool) Option

func WithOptionShowSlimeLine

func WithOptionShowSlimeLine(showSlimeLine bool) Option

func WithWidth

func WithWidth(width int) Option

type Options

type Options struct {
	Engine               VerifyType
	OptionShowSineLine   bool
	OptionShowSlimeLine  bool
	OptionShowHollowLine bool
	Height               int
	Width                int
	CaptchaLen           int
	NoiseCount           int
	BgColor              string
	Audio                Audio
}

func (*Options) GetShowLine

func (o *Options) GetShowLine() int

type RedisStore

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

func (*RedisStore) Get

func (r *RedisStore) Get(id string, clear bool) string

func (*RedisStore) Provide

func (r *RedisStore) Provide(_ context.Context) interface{}

func (*RedisStore) Set

func (r *RedisStore) Set(id string, value string) error

func (*RedisStore) Verify

func (r *RedisStore) Verify(id, answer string, clear bool) bool

type Store

type Store interface {
	Set(id string, value string) error
	Get(id string, clear bool) string
	Verify(id, answer string, clear bool) bool
}

type VerifyType

type VerifyType uint8
const (
	VerifyTypeDigit     VerifyType = iota + 1 // 1 数字验证码
	VerifyTypeCharacter                       // 2 字符验证码
	VerifyTypeAudio                           // 3 音频验证码
	VerifyTypeLanguage                        // 4 语言验证码
	VerifyTypeMath                            // 5 数学验证码
	VerifyTypeChinese                         // 6 中文验证码
)

Jump to

Keyboard shortcuts

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