captcha

package
v0.0.0-...-b32e05d Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaptchaHolder

type CaptchaHolder struct {
	DefaultHeight  int     // 默认高度 40
	DefaultWidth   int     // 默认宽度 80
	DefaultLength  int     // 默认长度,位数 6
	DefaultMaxSkew float64 // 默认倾斜因子 0.7
	DefaultDotRate float64 // 默认干扰点比率 25%

	DriverAudio   *base64Captcha.DriverAudio
	DriverString  *base64Captcha.DriverString
	DriverChinese *base64Captcha.DriverChinese
	DriverMath    *base64Captcha.DriverMath
	DriverDigit   *base64Captcha.DriverDigit
	// contains filtered or unexported fields
}

验证码仓库

func NewCaptchaHolder

func NewCaptchaHolder(options ...Option) *CaptchaHolder

func (*CaptchaHolder) GetCodeCaptcha

func (rs *CaptchaHolder) GetCodeCaptcha(key string) (code string, err error)

生成随机验证码

func (*CaptchaHolder) GetImageCaptcha

func (rs *CaptchaHolder) GetImageCaptcha(CaptchaType string, height int, width int, length int) (string, string, error)

func (*CaptchaHolder) VerifyCaptcha

func (rs *CaptchaHolder) VerifyCaptcha(id string, answer string) bool

验证验证码

type Option

type Option func(*CaptchaHolder)

func WithRedisStore

func WithRedisStore(rdb *redis.Client) Option

type RedisStore

type RedisStore struct {
	Redis      *redis.Client // 缓存 15分钟
	Expiration time.Duration // 过期时间
	PrefixKey  string        // 前缀
	Context    context.Context
}

验证码存储

func NewRedisStore

func NewRedisStore(rd *redis.Client) *RedisStore

func (*RedisStore) Get

func (rs *RedisStore) Get(key string, clear bool) string

func (*RedisStore) Set

func (rs *RedisStore) Set(key string, value string) error

func (*RedisStore) Verify

func (rs *RedisStore) Verify(key, answer string, clear bool) bool

Jump to

Keyboard shortcuts

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