Coder Social home page Coder Social logo

wenlng / go-captcha Goto Github PK

View Code? Open in Web Editor NEW
1.5K 1.5K 135.0 27.85 MB

🖖 Go Captcha is a behavior security captcha, which implements text click verification, slide verification and rotation verification.

Home Page: http://gocaptcha.wencodes.com

License: Other

Go 100.00%
captcha captcha-generator click-captcha clickcaptcha go go-captcha gocaptcha image-captcha key-captcha keycaptcha rotate-captcha slide-captcha verification-code

go-captcha's Issues

是否考虑加入更多验证方式

查看 Demo 好像只支持「选择文字」验证方式,请问是否考虑加入诸如「滑动验证」「旋转验证」等验证方式。

capt.SetRangCheckTextLen 判断条件与变量名存在误导

// SetRangCheckTextLen is a function
/**
 * @Description: 设置随机验证文本长度
 * @receiver cc
 * @param val
 */
func (cc *Captcha) SetRangCheckTextLen(val RangeVal) {
	// 检测验证文本范围最大值是否小于随机字符串的最小范围
	if cc.config.rangCheckTextLen.Max > cc.config.rangTextLen.Min {
		panic(fmt.Errorf("CaptchaConfig Error: RangCheckTextLen.max must be less than or equal to RangTextLen.min"))
	}

	cc.config.rangCheckTextLen = val
}

不应该是
if cc.config.rangCheckTextLen.Max < cc.config.rangTextLen.Min {
}

文档再完善些,示例再精简些

大神好,这个项目达到了我想要的效果,很强大
但,文档太不友好了。。。(自学go一年多,表示完全上不了手)
给的go_captcha_demo(https://github.com/wenlng/go-captcha-example)
也和文档基本对不上啊

希望大神可以做成开箱即用的那种,js抽离出来,页面简洁些,验证码的生成、验证、以及缓存明确下。。。。

设置字符集为英文字母时,验证容易报错

  1. 设置英文字符集

chars := "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

_ = capt.SetRangChars(strings.Split(chars, ""))

capt = captcha.GetCaptcha()

dots, b64, tb64, key, err := capt.Generate()

  1. 前端点选结果

{"dot":"110,198,48,88,197,72","key":"c39190357e6e59043729c59a8fa99a71"}
image

  1. 实际点选结果
    {"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"}}

期望和汉字的验证效果一致

给诸位提个醒,关系文字的坐标的

正常情况下

  • 前端的坐标是以左上角来计算的,这毫无问题

和服务器储存的坐标信息对比,你会发现:

  • X轴的坐标信息是对的(Dx <= fontendX <= Dx+Width),这毫无问题
  • Y轴的坐标信息是错的,前端的Y轴坐标小于了后端的Y轴开始坐标,也就是(fontendY <= Dy <= Dy_Height),你肯定会很紧张,以为自己算错了

把心放肚子里

  • 这是因为文字的坐标是以文字的左下角为原点的,也就是说服务端储存的Dy值已经是加上了Height之后的值了
  • 前端不需要任何处理,后端会在比对的时候自动减去Height值再进行比对,也就是(Dy - Height)≈ fontendY
  • 所以放心大胆的把这个看起来错误的Y值传给服务器,它会自己处理的

There is a problem with the order of return variables in the comment

// Generate is a function
/**

  • @description: 根据设置的尺寸生成验证码图片
  • @return CaptchaCharDot 位置信息
  • @return string 主图Base64
  • @return string 验证码KEY
  • @return string 缩略图Base64
  • @return error
    */
    func (cc *Captcha) Generate() (map[int]CharDot, string, string, string, error) {
    dots, ib64, tb64, key, err := cc.GenerateWithSize(cc.config.imageSize, cc.config.thumbnailSize)
    return dots, ib64, tb64, key, err
    }

There may be misunderstandings about the first use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.