kk_captcha

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCaptcha

func GenerateCaptcha() (id string, b64s string, err error)

GenerateCaptcha 验证码生成

func VerifyCaptcha

func VerifyCaptcha(id string, answer string) (res bool)

Types

type CaptchaReq

type CaptchaReq struct {
	// 验证码过期时间
	ExpireTime time.Duration
	//  验证码请求时间限制
	RequestTimeLimit time.Duration
	// 验证码请求来源,用于限制请求频次
	RequestFor string
	// phone or email
	Target string
	// 验证码长度
	Length uint32
	// 验证码类型
	Type CaptchaType
	// 验证码生成,为空时使用默认生成
	CodeGenFunc func() (string, error)
	// 发送验证码
	SendFunc func() error
	// contains filtered or unexported fields
}

func (*CaptchaReq) RequestCaptcha

func (x *CaptchaReq) RequestCaptcha() (captchaResp *CaptchaResp, err error)

type CaptchaResp

type CaptchaResp struct {
	CaptchaId   string
	CaptchaCode string
}

type CaptchaType

type CaptchaType int
const (
	CaptchaTypePhone CaptchaType = iota
	CaptchaTypeEmail
)

type CaptchaValidator

type CaptchaValidator struct {
	CaptchaId   string
	CaptchaCode string
}

func (*CaptchaValidator) CheckCaptcha

func (x *CaptchaValidator) CheckCaptcha() error

Jump to

Keyboard shortcuts

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