captcha

package
v0.0.0-...-5c0bb04 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const CacheKeyPrefix = "captcha_"

CacheKeyPrefix captcha cache key prefix

View Source
const LifeTime = 3600

LifeTime captcha validity period

Variables

This section is empty.

Functions

func CacheKey

func CacheKey(key string) string

CacheKey get captcha cache key

func Check

func Check(token, code string) bool

Check validity for captcha token and code

func NextTimeNeed

func NextTimeNeed(ctx echo.Context, id, action string, maxCount, period int) bool

NextTimeNeed does the next request require a captcha?

Types

type Form

type Form struct {
	CaptchaToken string `json:"captcha_token"`
	CaptchaCode  string `json:"captcha_code"`
}

Form receive form for captcha

type Present

type Present struct {
	CaptchaImage string `json:"captcha_image"`
	CaptchaToken string `json:"captcha_token"`
}

Present result struct for captcha

func Generate

func Generate(width, height int) (*Present, error)

Generate return a *Captcha set width = 100 if width value is 0 set height = 36 if height value is 0

func (Present) Format

func (p Present) Format() interface{}

Format return a response format data

Jump to

Keyboard shortcuts

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