97 lines
2.3 KiB
Go
97 lines
2.3 KiB
Go
|
|
// captcha https://captcha.mojotv.cn/
|
||
|
|
package captcha
|
||
|
|
|
||
|
|
import (
|
||
|
|
"image/color"
|
||
|
|
|
||
|
|
"github.com/mojocn/base64Captcha"
|
||
|
|
)
|
||
|
|
|
||
|
|
// configJsonBody json request body.
|
||
|
|
type configJsonBody struct {
|
||
|
|
DriverAudio *base64Captcha.DriverAudio
|
||
|
|
DriverString *base64Captcha.DriverString
|
||
|
|
DriverChinese *base64Captcha.DriverChinese
|
||
|
|
DriverMath *base64Captcha.DriverMath
|
||
|
|
DriverDigit *base64Captcha.DriverDigit
|
||
|
|
}
|
||
|
|
|
||
|
|
// digitConfig 生成图形化数字验证码配置
|
||
|
|
func digitConfig() *base64Captcha.DriverDigit {
|
||
|
|
digitType := &base64Captcha.DriverDigit{
|
||
|
|
Height: 50,
|
||
|
|
Width: 100,
|
||
|
|
Length: 4,
|
||
|
|
MaxSkew: 0.45,
|
||
|
|
DotCount: 50,
|
||
|
|
}
|
||
|
|
return digitType
|
||
|
|
}
|
||
|
|
|
||
|
|
// mathConfig 生成图形化算术验证码配置
|
||
|
|
func mathConfig() *base64Captcha.DriverMath {
|
||
|
|
mathType := &base64Captcha.DriverMath{
|
||
|
|
Height: 50,
|
||
|
|
Width: 150,
|
||
|
|
NoiseCount: 0,
|
||
|
|
ShowLineOptions: 0,
|
||
|
|
BgColor: &color.RGBA{
|
||
|
|
R: 0,
|
||
|
|
G: 0,
|
||
|
|
B: 0,
|
||
|
|
A: 0,
|
||
|
|
},
|
||
|
|
Fonts: []string{"RitaSmith.ttc"},
|
||
|
|
}
|
||
|
|
return mathType
|
||
|
|
}
|
||
|
|
|
||
|
|
// stringConfig 生成图形化字符串验证码配置
|
||
|
|
func stringConfig() *base64Captcha.DriverString {
|
||
|
|
stringType := &base64Captcha.DriverString{
|
||
|
|
Height: 100,
|
||
|
|
Width: 50,
|
||
|
|
NoiseCount: 0,
|
||
|
|
ShowLineOptions: base64Captcha.OptionShowHollowLine | base64Captcha.OptionShowSlimeLine,
|
||
|
|
Length: 5,
|
||
|
|
Source: "123456789qwertyuiopasdfghjklzxcvb",
|
||
|
|
BgColor: &color.RGBA{
|
||
|
|
R: 40,
|
||
|
|
G: 30,
|
||
|
|
B: 89,
|
||
|
|
A: 29,
|
||
|
|
},
|
||
|
|
Fonts: nil,
|
||
|
|
}
|
||
|
|
return stringType
|
||
|
|
}
|
||
|
|
|
||
|
|
// chineseConfig 生成图形化汉字验证码配置
|
||
|
|
func chineseConfig() *base64Captcha.DriverChinese {
|
||
|
|
chineseType := &base64Captcha.DriverChinese{
|
||
|
|
Height: 50,
|
||
|
|
Width: 100,
|
||
|
|
NoiseCount: 0,
|
||
|
|
ShowLineOptions: base64Captcha.OptionShowSlimeLine,
|
||
|
|
Length: 2,
|
||
|
|
Source: "设想,你在,处理,消费者,的音,频输,出音,频可,能无,论什,么都,没有,任何,输出,或者,它可,能是,单声道,立体声,或是,环绕立,体声的,不想要,的值",
|
||
|
|
BgColor: &color.RGBA{
|
||
|
|
R: 40,
|
||
|
|
G: 30,
|
||
|
|
B: 89,
|
||
|
|
A: 29,
|
||
|
|
},
|
||
|
|
Fonts: nil,
|
||
|
|
}
|
||
|
|
return chineseType
|
||
|
|
}
|
||
|
|
|
||
|
|
// audioConfig 生成图形化数字音频验证码配置
|
||
|
|
func audioConfig() *base64Captcha.DriverAudio {
|
||
|
|
chineseType := &base64Captcha.DriverAudio{
|
||
|
|
Length: 4,
|
||
|
|
Language: "zh",
|
||
|
|
}
|
||
|
|
return chineseType
|
||
|
|
}
|