first commit
This commit is contained in:
18
internal/service/captcha/captcha.go
Normal file
18
internal/service/captcha/captcha.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package captcha
|
||||
|
||||
import "github.com/mojocn/base64Captcha"
|
||||
|
||||
var captchaStore base64Captcha.Store = base64Captcha.DefaultMemStore
|
||||
|
||||
func Generate(height int, width int, length int, maxSkew float64, dotCount int) (id, b64s, answer string, err error) {
|
||||
driver := base64Captcha.NewDriverDigit(height, width, length, maxSkew, dotCount)
|
||||
// driver := base64Captcha.NewDriverString(config.File.Captcha.ImgHeight,
|
||||
// config.File.Captcha.ImgWidth,
|
||||
// 6, 1, keyLong, source, nil, nil, nil)
|
||||
cp := base64Captcha.NewCaptcha(driver, captchaStore)
|
||||
return cp.Generate()
|
||||
}
|
||||
|
||||
func Verify(id, answer string, clear bool) bool {
|
||||
return captchaStore.Verify(id, answer, clear)
|
||||
}
|
||||
Reference in New Issue
Block a user