captcha

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaptchaConfig

type CaptchaConfig struct {
	Expir int64 `json:"expir" toml:"expir" yaml:"expir"` // 过期时间
}

type Email

type Email struct {
	Client *cache.Client
	Email  *email.Email
}

func NewEmail

func NewEmail(c *cache.Client, e *email.Email) *Email

func (*Email) Generate

func (c *Email) Generate(email any, expir time.Duration) (string, error)

func (*Email) SendEmailCode

func (e *Email) SendEmailCode(to string, code string, subject string, expir time.Duration) error

func (*Email) Verify

func (e *Email) Verify(email any, uuid string, code string) error

type Image

type Image struct {
	Client *cache.Client
	Config *ImageConfig
}

func NewImage

func NewImage(c *cache.Client, config *ImageConfig) *Image

func (*Image) Generate

func (i *Image) Generate(expir time.Duration) (string, string, error)

创建图片验证码

func (*Image) Verify

func (i *Image) Verify(uuid string, code string) error

验证

type ImageConfig

type ImageConfig struct {
	Width      int `json:"width" toml:"width" yaml:"width"`
	Height     int `json:"height" toml:"height" yaml:"height"`
	Length     int `json:"length" toml:"length" yaml:"length"`
	NoiseCount int `json:"noise_count" toml:"noise_count" yaml:"noise_count"` // 噪点数量
}

type InputCaptcha

type InputCaptcha interface {
	Generate(carrier string, expir time.Duration) (string, error)
	Verify(carrier string, uuid, code string) error
}

type OutputCaptcha

type OutputCaptcha interface {
	Generate(expir time.Duration) (string, string, error)
	Verify(uuid, code string) error
}

type Sms

type Sms struct {
	Client *cache.Client
	AliSms *ali.AliSms
}

func NewSms

func NewSms(c *cache.Client, a *ali.AliSms) *Sms

func (*Sms) Generate

func (s *Sms) Generate(mobile any, expir time.Duration) (string, error)

func (Sms) SendSmsCode

func (s Sms) SendSmsCode(mobile string, code string) error

func (*Sms) Verify

func (s *Sms) Verify(mobile any, uuid string, code string) error

type Value

type Value struct {
	Code    string
	Carrier string
}

Jump to

Keyboard shortcuts

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