Versions in this module Expand all Collapse all v1 v1.3.3 Apr 7, 2021 Changes in this version + const Emoji + const MimeTypeAudio + const MimeTypeImage + const OptionShowHollowLine + const OptionShowSineLine + const OptionShowSlimeLine + const TxtAlphabet + const TxtChineseCharaters + const TxtNumbers + const TxtSimpleCharaters + var DefaultDriverAudio = NewDriverAudio(6, "en") + 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 DriverAudio struct + Language string + Length int + func NewDriverAudio(length int, language string) *DriverAudio + func (d *DriverAudio) DrawCaptcha(content string) (item Item, err error) + func (d *DriverAudio) GenerateIdQuestionAnswer() (id, q, a string) + type DriverChinese struct + BgColor *color.RGBA + Fonts []string + Height int + Length int + NoiseCount int + ShowLineOptions int + Source string + Width int + func NewDriverChinese(height int, width int, noiseCount int, showLineOptions int, length int, ...) *DriverChinese + func (d *DriverChinese) ConvertFonts() *DriverChinese + func (d *DriverChinese) DrawCaptcha(content string) (item Item, err error) + func (d *DriverChinese) GenerateIdQuestionAnswer() (id, content, answer 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 DriverLanguage struct + BgColor *color.RGBA + Fonts []*truetype.Font + Height int + LanguageCode string + Length int + NoiseCount int + ShowLineOptions int + Width int + func NewDriverLanguage(height int, width int, noiseCount int, showLineOptions int, length int, ...) *DriverLanguage + func (d *DriverLanguage) DrawCaptcha(content string) (item Item, err error) + func (d *DriverLanguage) GenerateIdQuestionAnswer() (id, content, answer string) + type DriverMath struct + BgColor *color.RGBA + Fonts []string + Height int + NoiseCount int + ShowLineOptions int + Width int + func NewDriverMath(height int, width int, noiseCount int, showLineOptions int, ...) *DriverMath + func (d *DriverMath) ConvertFonts() *DriverMath + func (d *DriverMath) DrawCaptcha(question string) (item Item, err error) + func (d *DriverMath) GenerateIdQuestionAnswer() (id, question, answer string) + type DriverString struct + BgColor *color.RGBA + Fonts []string + Height int + Length int + NoiseCount int + ShowLineOptions int + Source string + Width int + func NewDriverString(height int, width int, noiseCount int, showLineOptions int, length int, ...) *DriverString + func (d *DriverString) ConvertFonts() *DriverString + func (d *DriverString) DrawCaptcha(content string) (item Item, err error) + func (d *DriverString) GenerateIdQuestionAnswer() (id, content, answer string) + type Item interface + EncodeB64string func() string + WriteTo func(w io.Writer) (n int64, err error) + type ItemAudio struct + func (a *ItemAudio) EncodeB64string() string + func (a *ItemAudio) WriteTo(w io.Writer) (n int64, err error) + type ItemChar struct + func NewItemChar(w int, h int, bgColor color.RGBA) *ItemChar + func (item *ItemChar) BinaryEncoding() []byte + func (item *ItemChar) EncodeB64string() string + func (item *ItemChar) WriteTo(w io.Writer) (int64, 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