captcha

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnabled = errors.New("captcha: not enabled")
	ErrIDEmpty    = errors.New("captcha: id is empty")
)

Functions

func Init

func Init(opts *Options)

Types

type Captcha

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

func (*Captcha) Get

func (c *Captcha) Get() *Value

Get 获取验证码

func (*Captcha) GetEnabled

func (c *Captcha) GetEnabled() bool

func (*Captcha) Show

func (c *Captcha) Show(ctx *gin.Context, id string) error

Show 展示验证码

func (*Captcha) Verify

func (c *Captcha) Verify(val *Value) bool

Verify 验证验证码

type Options

type Options struct {
	Enabled   bool
	StoreMode int8
	Len       int
	Width     int
	Height    int
	Rds       *redis.Client
}

type StoreMode

type StoreMode int8

type Value

type Value struct {
	ID   string `json:"id,omitempty"`
	Code string `json:"code,omitempty"`
	Img  string `json:"img,omitempty"`
	Len  int    `json:"len,omitempty"`
}

Jump to

Keyboard shortcuts

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