captcha

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CR

type CR struct {
	// id 验证码ID
	Id string `json:"id"`
	// B64 b64s 验证码图片
	B64 string `json:"b64"`
	// Value 验证码值
	Value string `json:"value"`
	// Clear 是否清除
	Clear bool `json:"clear"`
	// Length 验证码长度
	Length int `json:"length"`
}

CR 验证码

type Captcha

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

Captcha 单例

func GetInstance

func GetInstance() *Captcha

GetInstance 获取配置实例

func (*Captcha) Generate

func (o *Captcha) Generate() (*CR, error)

Generate 生成验证码

func (*Captcha) Verify

func (o *Captcha) Verify(r *CR) bool

Verify 验证验证码

type RedisStore

type RedisStore struct {
	// Expiration 验证码过期时间
	Expiration time.Duration
	// PreKey 前缀
	PreKey string
}

RedisStore redis存储

func NewRedisStore

func NewRedisStore() *RedisStore

func (*RedisStore) Get

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

Get 获取

func (*RedisStore) Key

func (o *RedisStore) Key(key string) string

Key 根据id生成key

func (*RedisStore) Set

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

Set 设置

func (*RedisStore) Verify

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

Verify 验证

Jump to

Keyboard shortcuts

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