go-captcha
go-captcha copied to clipboard
设置字符集为英文字母时,验证容易报错
- 设置英文字符集
chars := "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
_ = capt.SetRangChars(strings.Split(chars, ""))
capt = captcha.GetCaptcha()
dots, b64, tb64, key, err := capt.Generate()
- 前端点选结果
{"dot":"110,198,48,88,197,72","key":"c39190357e6e59043729c59a8fa99a71"}
- 实际点选结果 {"0":{"Index":0,"Dx":105,"Dy":227,"Size":38,"Width":38,"Height":38,"Text":"N","Angle":330,"Color":"#fcb08e","Color2":"#6e3700"},"1":{"Index":1,"Dx":50,"Dy":111,"Size":31,"Width":31,"Height":31,"Text":"A","Angle":20,"Color":"#60c1ff","Color2":"#6e3700"},"2":{"Index":2,"Dx":193,"Dy":96,"Size":37,"Width":37,"Height":37,"Text":"F","Angle":325,"Color":"#b4fed4","Color2":"#660033"}}
期望和汉字的验证效果一致
- 设置英文字符集
chars := "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
_ = capt.SetRangChars(strings.Split(chars, ""))
capt = captcha.GetCaptcha()
dots, b64, tb64, key, err := capt.Generate()
- 前端点选结果
{"dot":"110,198,48,88,197,72","key":"c39190357e6e59043729c59a8fa99a71"}
- 实际点选结果 {"0":{"Index":0,"Dx":105,"Dy":227,"Size":38,"Width":38,"Height":38,"Text":"N","Angle":330,"Color":"#fcb08e","Color2":"#6e3700"},"1":{"Index":1,"Dx":50,"Dy":111,"Size":31,"Width":31,"Height":31,"Text":"A","Angle":20,"Color":"#60c1ff","Color2":"#6e3700"},"2":{"Index":2,"Dx":193,"Dy":96,"Size":37,"Width":37,"Height":37,"Text":"F","Angle":325,"Color":"#b4fed4","Color2":"#660033"}}
期望和汉字的验证效果一致
嘿嘿,v2 的位置计算将更精准了,即将发布,可关注一下!
