Spaces:
Sleeping
Sleeping
File size: 489 Bytes
bb9df9e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package utils
import (
"image/color"
"github.com/mojocn/base64Captcha"
)
var store = base64Captcha.DefaultMemStore
// GetCaptcha 获取验证码
func GetCaptcha() (string, string, string, error) {
driver := base64Captcha.NewDriverMath(60, 180, 80, 0, &color.RGBA{255, 255, 255, 255}, nil, nil)
return base64Captcha.NewCaptcha(driver, store).Generate()
}
// VerifyCaptcha 验证验证码
func VerifyCaptcha(id string, answer string) bool {
return store.Verify(id, answer, true)
}
|