Versions in this module Expand all Collapse all v1 v1.3.5 Jul 17, 2021 Changes in this version + const MimeTypeImage + const TxtAlphabet + const TxtNumbers + var DefaultDriverDigit = NewDriverDigit(80, 240, 5, 0.7, 80) + var DefaultMemStore = NewMemoryStore(GCLimitNumber, Expiration) + var Expiration = 10 * time.Minute + var GCLimitNumber = 10240 + func RandColor() color.RGBA + func RandDeepColor() color.RGBA + func RandLightColor() color.RGBA + func RandText(size int, sourceChars string) string + func RandomId() string + type Captcha struct + Driver Driver + Store Store + func NewCaptcha(driver Driver, store Store) *Captcha + func (c *Captcha) Generate() (id, b64s string, err error) + func (c *Captcha) Verify(id, answer string, clear bool) (match bool) + type Driver interface + DrawCaptcha func(content string) (item Item, err error) + GenerateIdQuestionAnswer func() (id, q, a string) + type DriverDigit struct + DotCount int + Height int + Length int + MaxSkew float64 + Width int + func NewDriverDigit(height int, width int, length int, maxSkew float64, dotCount int) *DriverDigit + func (d *DriverDigit) DrawCaptcha(content string) (item Item, err error) + func (d *DriverDigit) GenerateIdQuestionAnswer() (id, q, a string) + type Item interface + EncodeB64string func() string + WriteTo func(w io.Writer) (n int64, err error) + type ItemDigit struct + func NewItemDigit(width int, height int, dotCount int, maxSkew float64) *ItemDigit + func (m *ItemDigit) EncodeB64string() string + func (m *ItemDigit) EncodeBinary() []byte + func (m *ItemDigit) WriteTo(w io.Writer) (int64, error) + type Store interface + Get func(id string, clear bool) string + Set func(id string, value string) + Verify func(id, answer string, clear bool) bool + func NewMemoryStore(collectNum int, expiration time.Duration) Store + type StoreSyncMap struct + func NewStoreSyncMap(liveTime time.Duration) *StoreSyncMap + func (s StoreSyncMap) Get(id string, clear bool) string + func (s StoreSyncMap) Set(id string, value string) + func (s StoreSyncMap) Verify(id, answer string, clear bool) bool