captcha

package
v0.0.0-...-0cfe181 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//TxtNumbers chacters for numbers.
	TxtNumbers = "012346789"
	//TxtAlphabet characters for alphabet.
	TxtAlphabet = "ABCDEFGHJKMNOQRSTUVXYZabcdefghjkmnoqrstuvxyz"
)

Variables

View Source
var (
	GCLimitNumber   = 1024
	Expiration      = 5 * time.Minute
	DefaultMemStore = NewMemoryStore(GCLimitNumber, Expiration)
)

Functions

func CreateCaptcha

func CreateCaptcha() string

func DriverDigitFunc

func DriverDigitFunc() (id, bs string, err error)

func RandColor

func RandColor() color.RGBA

RandColor get random color. 生成随机颜色.

func RandDeepColor

func RandDeepColor() color.RGBA

RandDeepColor get random deep color. 随机生成深色系.

func RandLightColor

func RandLightColor() color.RGBA

RandLightColor get random ligth color. 随机生成浅色.

func RandText

func RandText(size int, sourceChars string) string

RandText creates random text of given size.

func RandomId

func RandomId() string

RandomId returns a new random id key string.

func Verify

func Verify(id, val string, clear bool) bool

Types

type Store

type Store interface {
	// Set sets the digits for the captcha id.
	Set(id string, value string)
	// Get returns stored digits for the captcha id. Clear indicates
	// whether the captcha must be deleted from the store.
	Get(id string, clear bool) string
	//Verify captcha's answer directly
	Verify(id, answer string, clear bool) bool
}

func NewMemoryStore

func NewMemoryStore(collectNum int, expiration time.Duration) Store

Jump to

Keyboard shortcuts

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