| 1234567891011121314151617181920212223242526272829303132333435 |
- package utl
- import (
- "github.com/mojocn/base64Captcha"
- )
- var (
- store = base64Captcha.DefaultMemStore
- )
- type DigitCatpcha struct {
- h *base64Captcha.Captcha
- }
- func NewDigitCatpcha(length int) *DigitCatpcha {
- driver := &base64Captcha.DriverDigit{
- Height: 80,
- Width: 240,
- Length: length,
- MaxSkew: 0.7,
- DotCount: 80,
- }
- return &DigitCatpcha{
- h: base64Captcha.NewCaptcha(driver, store),
- }
- }
- func (self *DigitCatpcha) Gen() (id, b64 string, err error) {
- id, b64, err = self.h.Generate()
- return
- }
- func (self *DigitCatpcha) Verify(id, value string) bool {
- return store.Verify(id, value, true)
- }
|