You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1010 B

2 years ago
package captcha
import (
"github.com/mojocn/base64Captcha"
)
func GetCaptcha() (string, string) {
//config struct for Character
//字符,公式,验证码配置
var configC = base64Captcha.ConfigCharacter{
Height: 30,
Width: 80,
//const CaptchaModeNumber:数字,CaptchaModeAlphabet:字母,CaptchaModeArithmetic:算术,CaptchaModeNumberAlphabet:数字字母混合.
Mode: base64Captcha.CaptchaModeNumber,
ComplexOfNoiseText: base64Captcha.CaptchaComplexLower,
ComplexOfNoiseDot: base64Captcha.CaptchaComplexLower,
IsUseSimpleFont: true,
IsShowHollowLine: false,
IsShowNoiseDot: false,
IsShowNoiseText: false,
IsShowSlimeLine: false,
IsShowSineLine: false,
CaptchaLen: 4,
}
idKeyC, capC := base64Captcha.GenerateCaptcha("", configC)
base64stringC := base64Captcha.CaptchaWriteToBase64Encoding(capC)
return idKeyC, base64stringC
}
func Verify(idKey, verifyValue string) bool {
return base64Captcha.VerifyCaptcha(idKey, verifyValue)
}