11package captcha
22
33import (
4+ "image/color"
45 "strings"
56
67 "github.com/1Panel-dev/1Panel/core/app/dto"
@@ -9,6 +10,16 @@ import (
910
1011var store = base64Captcha .DefaultMemStore
1112
13+ const (
14+ captchaWidth = 160
15+ captchaHeight = 48
16+ captchaNoise = 0
17+ )
18+
19+ var captchaFonts = []string {
20+ base64Captcha .FontRitaSmith ,
21+ }
22+
1223func VerifyCode (codeID string , code string ) string {
1324 vv := store .Get (codeID , true )
1425 vv = strings .TrimSpace (vv )
@@ -23,14 +34,15 @@ func VerifyCode(codeID string, code string) string {
2334}
2435
2536func CreateCaptcha () (* dto.CaptchaResponse , error ) {
26- var driverString base64Captcha.DriverString
27- driverString .Source = "1234567890QWERTYUPLKJHGFDSAZXCVBNMqwertyupkjhgfdsazxcvbnm"
28- driverString .Width = 120
29- driverString .Height = 50
30- driverString .NoiseCount = 0
31- driverString .Length = 4
32- driverString .Fonts = []string {"RitaSmith.ttf" , "actionj.ttf" , "chromohv.ttf" }
33- driver := driverString .ConvertFonts ()
37+ driver := base64Captcha .NewDriverMath (
38+ captchaHeight ,
39+ captchaWidth ,
40+ captchaNoise ,
41+ 0 ,
42+ & color.RGBA {R : 246 , G : 248 , B : 251 , A : 255 },
43+ nil ,
44+ captchaFonts ,
45+ )
3446 c := base64Captcha .NewCaptcha (driver , store )
3547 id , b64s , _ , err := c .Generate ()
3648 if err != nil {
0 commit comments