captcha

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustNewOriginalRedisCaptcha added in v1.2.8

func MustNewOriginalRedisCaptcha(c Conf, r redis.UniversalClient) *base64Captcha.Captcha

MustNewOriginalRedisCaptcha returns the captcha using original go redis, it will exit when error occur

func MustNewRedisCaptcha added in v1.0.2

func MustNewRedisCaptcha(c Conf, r *redis2.Redis) *base64Captcha.Captcha

MustNewRedisCaptcha returns the captcha using redis, it will exit when error occur

func NewDriver added in v1.0.2

func NewDriver(c Conf) base64Captcha.Driver

Types

type Conf added in v1.0.2

type Conf struct {
	KeyLong   int    `json:",optional,default=5,env=CAPTCHA_KEY_LONG"`                                       // captcha length
	ImgWidth  int    `json:",optional,default=240,env=CAPTCHA_IMG_WIDTH"`                                    // captcha width
	ImgHeight int    `json:",optional,default=80,env=CAPTCHA_IMG_HEIGHT"`                                    // captcha height
	Driver    string `json:",optional,default=digit,options=[digit,string,math,chinese],env=CAPTCHA_DRIVER"` // captcha type
}

Conf is the captcha configuration structure

type OriginalRedisStore added in v1.2.8

type OriginalRedisStore struct {
	Expiration time.Duration
	PreKey     string
	Context    context.Context
	Redis      redis.UniversalClient
}

OriginalRedisStore stores captcha data.

func NewOriginalRedisStore added in v1.2.8

func NewOriginalRedisStore(r redis.UniversalClient) *OriginalRedisStore

NewOriginalRedisStore returns a redis store for captcha.

func (*OriginalRedisStore) Get added in v1.2.8

func (r *OriginalRedisStore) Get(key string, clear bool) string

Get gets the captcha KV from redis.

func (*OriginalRedisStore) Set added in v1.2.8

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

Set sets the captcha KV to redis.

func (*OriginalRedisStore) UseWithCtx added in v1.2.8

UseWithCtx add context for captcha.

func (*OriginalRedisStore) Verify added in v1.2.8

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

Verify verifies the captcha whether it is correct.

type RedisStore

type RedisStore struct {
	Expiration time.Duration
	PreKey     string
	Context    context.Context
	Redis      *redis.Redis
}

RedisStore stores captcha data.

func NewRedisStore

func NewRedisStore(r *redis.Redis) *RedisStore

NewRedisStore returns a redis store for captcha.

func (*RedisStore) Get

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

Get gets the captcha KV from redis.

func (*RedisStore) Set

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

Set sets the captcha KV to redis.

func (*RedisStore) UseWithCtx

func (r *RedisStore) UseWithCtx(ctx context.Context) base64Captcha.Store

UseWithCtx add context for captcha.

func (*RedisStore) Verify

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

Verify verifies the captcha whether it is correct.

Jump to

Keyboard shortcuts

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