forked from jimmykuu/gopher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
captcha.go
39 lines (33 loc) · 928 Bytes
/
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
31
32
33
34
35
36
37
38
39
package apis
import (
"strings"
"github.com/mojocn/base64Captcha"
"github.com/pborman/uuid"
)
type Captcha struct {
Base
}
// Get /api/captcha
func (c *Captcha) Get() interface{} {
var config = base64Captcha.ConfigCharacter{
Height: 60,
Width: 150,
Mode: base64Captcha.CaptchaModeNumberAlphabet,
IsUseSimpleFont: true,
ComplexOfNoiseText: 2,
ComplexOfNoiseDot: 20,
IsShowHollowLine: true,
IsShowNoiseDot: true,
IsShowNoiseText: false,
IsShowSlimeLine: false,
IsShowSineLine: false,
CaptchaLen: 6,
}
captchaID, captcaInterfaceInstance := base64Captcha.GenerateCaptcha(strings.Replace(uuid.NewUUID().String(), "-", "", -1), config)
base64blob := base64Captcha.CaptchaWriteToBase64Encoding(captcaInterfaceInstance)
return map[string]interface{}{
"data": base64blob,
"captcha_id": captchaID,
"status": 1,
}
}