captcha

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package captcha

@author: xwc1125

Package captcha

@author: xwc1125

Index

Constants

View Source
const (
	Unknown = "unknown"
	Audio   = "audio"
	String  = "string"
	Math    = "math"
	Chinese = "chinese"
)

Variables

View Source
var (
	Height     = 80
	Width      = 240
	Length     = 6
	Color      = &color.RGBA{R: 254, G: 254, B: 254, A: 254}
	NoiseCount = 80

	DefaultMemStore    = base64Captcha.DefaultMemStore
	DefaultDriverAudio = base64Captcha.DefaultDriverAudio
)
View Source
var (
	CaptchaPrefixKey = "captcha_"
)

Functions

func Generate

func Generate(store Store, captchaType string) (id, b64s string, err error)

Generate 生成验证码

func GenerateDefault

func GenerateDefault(captchaType string) (id, b64s string, err error)

func Verify

func Verify(store Store, id, answer string, clear bool) bool

Verify 验证验证码

func VerifyDefault

func VerifyDefault(id, answer string, clear bool) bool

Types

type Driver

type Driver struct {
	DriverAudio   *base64Captcha.DriverAudio
	DriverString  *base64Captcha.DriverString
	DriverChinese *base64Captcha.DriverChinese
	DriverMath    *base64Captcha.DriverMath
	DriverDigit   *base64Captcha.DriverDigit
}

Driver 驱动

type RedisStore

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

func NewRedisStore

func NewRedisStore(db *redis.DB) (*RedisStore, error)

func NewRedisStoreByConfig

func NewRedisStoreByConfig(config redis.RedisConfig) (*RedisStore, error)

func (*RedisStore) Get

func (s *RedisStore) Get(id string, clear bool) string

func (*RedisStore) Set

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

func (*RedisStore) Verify

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

type Store

type Store base64Captcha.Store

Jump to

Keyboard shortcuts

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