:sunglasses:Package captcha provides an easy to use, unopinionated API for captcha generation

Package captcha provides an easy to use, unopinionated API for captcha generation.

PkgGoDev Build Status codecov Go Report Card

Why another captcha generator?

I want a simple and framework-independent way to generate captcha. It also should be flexible, at least allow me to pick my favorite font.

install

go get github.com/steambap/captcha

usage

func handle(w http.ResponseWriter, r *http.Request) {
	// create a captcha of 150x50px
	data, _ := captcha.New(150, 50)

	// session come from other library such as gorilla/sessions
	session.Values["captcha"] = data.Text
	session.Save(r, w)
	// send image data to client
	data.WriteImage(w)
}

documentation | example

sample image

image

image

Contributing

If your found a bug, please contribute! see contributing.md for more detail.

License

MIT

Similar Resources

HyperKit: an easy-to-use bridge between LedFX, WLED, Bluetooth, HomeKit, and AirPlay2

HyperKit HyperKit is an easy-to-use bridge between LedFX, WLED, Bluetooth, HomeKit, and AirPlay2. HyperKit Functionality: Custom HomeKit Menu Integrat

Aug 20, 2022

[Building]Use Go & Vue3 to build an easy blog

Go + Vue3 Study 环境安装 本地环境:Go 1.17 后端框架:Gin 注意Go在使用Go Module的话需要使用修改Go的代理 首先查看Go相关的环境变量 go env 修改Go代理 go env -w Go111MODULE=on go env -w GOPROXY=https:

Jan 25, 2022

A easy-to-use and lightweight Go RPC framwork

zrpc 一个简单易用的Go RPC框架 功能 负载均衡(一致性哈希,Round-Robin, 随机) 服务注册与发现 心跳功能 超时处理(调用超时,连接超时,处理超时) 支持TCP/HTTP网络协议 连接复用 同步/异步调用 支持gob/json序列化协议 简单用法 创建注册中心 l, _ :=

Oct 30, 2022

Support CI generation of SBOMs via golang tooling.

Software Package Data Exchange (SPDX) is an open standard for communicating software bill of materials (SBOM) information that supports accurate identification of software components, explicit mapping of relationships between components, and the association of security and licensing information with each component.

Jan 3, 2023

Set of functions/methods that will ease GO code generation

Set of functions/methods that will ease GO code generation

Dec 1, 2021

Support CI generation of SBOMs via golang tooling.

Support CI generation of SBOMs via golang tooling.

SPDX Software Bill of Materials (SBOM) Generator Overview Software Package Data Exchange (SPDX) is an open standard for communicating software bill of

Jan 3, 2023

Code generation for golang's constructor

constructor Generate constructor for a given struct. Usage of constructor: -exclude string the fields to exclude. Use comma to specify multi

Dec 26, 2021

Snowflake algorithm generation worker Id sequence

sequence snowflake algorithm generation worker Id sequence 使用雪花算法生成ID,生成100万个只需要

Jan 21, 2022

A test repo to demonstrate the current (go1.17.2) issue when trying to use retractA test repo to demonstrate the current (go1.17.2) issue when trying to use retract

test-go-mod-retract This is a test repo to demonstrate the current (go1.17.2) issue when trying to use retract in go.mod to retract a version in a non

Oct 16, 2021
Comments
  • 是否增加一个配置生成自定义文本

    是否增加一个配置生成自定义文本

    https://github.com/steambap/captcha/blob/6aa88d953f8e846f4988439de8238ad62956b9d2/captcha.go#L137

    如,增加一个:

    Generator: func() (string, string)
    

    目的自定义文本和结果 例如:生成一个 天上?? , 服务的session值: 人间

    text := ""
    equation := ""
    if options.Generator != nil {
        text, equation = options.Generator()
    } else {
        text, equation = randomEquation()
    }
    ......
    drawText(equation, img, options)
    

    eg.

    options.Generator = func() (text string, equation string) {
    	data := [][]string{
    		{"天上", "人间"},
    		{"守株", "待兔"},
    	}
    	item := data[rand.Intn(len(data))]
    	equation = item[0] + ":?"
    	text = item[1]
    	return
    }
    
  • Make New() concurrency-safe

    Make New() concurrency-safe

    A Source created by rand.NewSource() is not safe for concurrent use. To make this library concurrency-safe, I would suggest doing the following:

    • Use the top-level functions of math/rand package such as rand.Intn() and rand.Float64().
    • Provide a seed in init() function.
  • Globalvars

    Globalvars

    should be applied after:

    • https://github.com/steambap/captcha/pull/3
    • https://github.com/steambap/captcha/pull/2

    GlobalVars and Init functions inside package should not be used, this refactors a bit code to hide those variables and remove a need in Init function.

    Breaks a bit backward compatibility.

Kage Solutions - Finishline & JDSports Captcha API Integration

Kage Solutions - Finishline & JDSports Captcha API Integration

Feb 10, 2022
captcha of base64 and diversity

A flexible and various captcha package Base64captcha supports any unicode character and can easily be customized to support Math Chinese Korean Japane

Dec 26, 2022
Go code to generate Captcha letters for any TrueType font format files.

Go code to generate Captcha letters for any TrueType font format files. The code can be modified for the background and font colors. The code can be easily upgraded for distorted and rotated letters. These generated lettes can be stiched together to make captcha string.

Jan 31, 2022
Yubigo is a Yubikey client API library that provides an easy way to integrate the Yubico Yubikey into your existing Go-based user authentication infrastructure.

yubigo Yubigo is a Yubikey client API library that provides an easy way to integrate the Yubikey into any Go application. Installation Installation is

Oct 27, 2022
Knit is an inline code generation tool that combines the power of Go's text/template package with automatic spec file loading.

Knit Knit is an inline code generation tool that combines the power of Go's text/template package with automatic spec file loading. Example openapi: "

Sep 15, 2022
An easy to use, extensible health check library for Go applications.

Try browsing the code on Sourcegraph! Go Health Check An easy to use, extensible health check library for Go applications. Table of Contents Example M

Dec 30, 2022
An easy-to-use Map Reduce Go parallel-computing framework inspired by 2021 6.824 lab1. It supports multiple workers on a single machine right now.

MapReduce This is an easy-to-use Map Reduce Go framework inspired by 2021 6.824 lab1. Feature Multiple workers on single machine right now. Easy to pa

Dec 5, 2022
Hrple is an easy to use tool to help you create habits
Hrple is an easy to use tool to help you create habits

Hrple is an easy to use tool to help you create habits. This is loosely inspired by the book Atomic Habits by James Clear and techniques or frameworks like Kanban and the Pomodoro Technique.

Jun 2, 2022
Eye - An easy-use lib for event-driven pattern

?? Eye Eye 是一个简单易用的事件驱动模式库。 Read me in English ?? 功能特性 敬请期待。。。 历史版本的特性请查看 HISTOR

Jan 17, 2022
A fast and easy-to-use gutenberg book downloader

Gutenberg Downloader A brief description of what this project does and who it's for Usage download books Download all english books as epubs with imag

Jan 11, 2022