Skip to content

zxbit2011/gifCaptcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

gifCaptcha

gif 图形验证码

丰富自定义设置

  • 图片大小
  • 多颜色
  • 文字模式
  • 文字数量
  • 干扰强度

快速使用

> go get github.com/zxbit2011/gifCaptcha

示例代码

package main

import (
    "github.com/zxbit2011/gifCaptcha"
    "image/color"
    "image/gif"
    "net/http"
)

var captcha = gifCaptcha.New()

func main() {
    //设置颜色
    captcha.SetFrontColor(color.Black, color.RGBA{255, 0, 0, 255}, color.RGBA{0, 0, 255, 255}, color.RGBA{0, 153, 0, 255})
    http.HandleFunc("/img", func(w http.ResponseWriter, r *http.Request) {
        gifData, code := captcha.RangCaptcha()
        println(code)
        gif.EncodeAll(w, gifData)
    })
    http.ListenAndServe(":8080", nil)
}
  • 运行示例

cd examples && go run main.go

注意

需提供字体文件examples/comic.ttf 默认路径放到根目录

示例效果

黑白

code

彩色

code2

感谢

https://github.com/afocus/captcha

About

gif 验证码

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages