/
views_captcha.go
30 lines (27 loc) · 941 Bytes
/
views_captcha.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package marketplace
import (
"github.com/dchest/captcha"
"github.com/gocraft/web"
"github.com/mojocn/base64Captcha"
)
func (c *Context) ViewCaptchaImage(w web.ResponseWriter, r *web.Request) {
captcha.WriteImage(w, r.PathParams["captcha_id"], 300, 100)
}
func (c *Context) ViewCaptchaImageV2(w web.ResponseWriter, r *web.Request) {
var config = base64Captcha.ConfigCharacter{
Height: 60,
Width: 240,
Mode: base64Captcha.CaptchaModeArithmetic,
ComplexOfNoiseText: base64Captcha.CaptchaComplexLower,
ComplexOfNoiseDot: base64Captcha.CaptchaComplexLower,
IsUseSimpleFont: true,
IsShowHollowLine: true,
IsShowNoiseDot: true,
IsShowNoiseText: true,
IsShowSlimeLine: true,
IsShowSineLine: true,
CaptchaLen: 6,
}
_, captchaInterfaceIntance := base64Captcha.GenerateCaptcha(r.PathParams["captcha_id"], config)
captchaInterfaceIntance.WriteTo(w)
}