GithubHelp home page GithubHelp logo

qaison / captcha Goto Github PK

View Code? Open in Web Editor NEW

This project forked from afocus/captcha

0.0 1.0 0.0 4.18 MB

simple captcha for golang (go验证码生成器)

Home Page: http://afocus.github.io/captcha/

Go 100.00%

captcha's Introduction

golang实现的验证码 golang captcha

丰富自定义设置(字体,多颜色,验证码大小,文字模式,文字数量,干扰强度)

demo

colorsamplecolor2

使用 Start using it

Download and install it:

go get github.com/qAison/captcha

最简单的示例 sample use

// 验证码 ID
id := captcha.New()

oFile, _ := os.Create(id+".png")
defer oFile.Close()

// 写入文件
captcha.WriteImage(oFile, id)

设置 set options

cap := draw.New()

// 设置 图片大小
cap.SetSize(100, 30)

// 设置 干扰度
cap.Disturbance.SetNormal()

// 添加 字体
cap.AddFont("comic.ttf", "xxx.ttf")

// 设置 字体颜色
cap.SetFontColor(color.RGBA{255, 255, 255, 255})

// 设置 多个 背景色,将随机使用
cap.SetBackgroundColor(
    color.RGBA{255, 0, 0, 255},
    color.RGBA{0, 0, 255, 255},
    color.RGBA{0, 153, 0, 255},
    color.RGBA{185, 123, 131, 255},
    color.RGBA{185, 123, 43, 255},
    color.RGBA{82, 146, 114, 255},
    color.RGBA{82, 69, 114, 255},
    color.RGBA{22, 69, 114, 255},
)

// 创建 全数字 图片
img, val := cap.CreateDigit(4)

// 创建 全字母 图片
img, val := cap.CreateAlpha(4)

// 创建 字母 + 数字 图片
img, val := cap.CreateAlphaDigit(4)

// 创建 自定义字符 图片
img := cap.Create("abc123")


#### 网站中如果使用? how to use for web

look `_examples/web/main.go`


captcha's People

Contributors

afocus avatar qaison avatar smithfox avatar vodolaz095 avatar

Watchers

 avatar

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.