package captcha import ( "github.com/google/uuid" "github.com/mojocn/base64Captcha" ) var store = base64Captcha.DefaultMemStore // configJsonBody json request body. type configJsonBody struct { Id string CaptchaType string VerifyValue string DriverAudio *base64Captcha.DriverAudio DriverString *base64Captcha.DriverString DriverChinese *base64Captcha.DriverChinese DriverMath *base64Captcha.DriverMath DriverDigit *base64Captcha.DriverDigit } func DriverDigitFunc() (id, b64s string, err error) { e := configJsonBody{} e.Id = uuid.New().String() e.DriverDigit = base64Captcha.NewDriverDigit(80, 240, 4, 0.7, 80) driver := e.DriverDigit captcha := base64Captcha.NewCaptcha(driver, store) return captcha.Generate() }