GoCaptcha: A high-performance, interactive behavior captcha library for Go. Supporting click, slide, drag-drop, and rotation modes to secure your application
GoCaptcha: A high-performance, interactive behavior captcha library for Go. Supporting click, slide, drag-drop, and rotation modes to secure your application
English | 中文
GoCaptcha is a powerful, modular, and highly customizable behavioral CAPTCHA library that supports multiple interactive CAPTCHA types: Click, Slide, Drag-Drop, and Rotate.
⭐️ If it helps you, please give a star.
| Project | Desc |
|---|---|
| document | GoCaptcha Documentation |
| online demo | GoCaptcha Online Demo |
| go-captcha-example | Golang + Web + APP Example |
| go-captcha-assets | Embedded Resource Assets for Golang |
| go-captcha | Golang CAPTCHA Library |
| go-captcha-jslib | JavaScript CAPTCHA Library |
| go-captcha-vue | Vue CAPTCHA Library |
| go-captcha-react | React CAPTCHA Library |
| go-captcha-angular | Angular CAPTCHA Library |
| go-captcha-svelte | Svelte CAPTCHA Library |
| go-captcha-solid | Solid CAPTCHA Library |
| go-captcha-uni | UniApp CAPTCHA, compatible with Apps, Mini-Programs, and Fast Apps |
| go-captcha-service | GoCaptcha Service, supports binary and Docker image deployment, provides HTTP/gRPC interfaces, supports standalone and distributed modes (service discovery, load balancing, dynamic configuration) |
| go-captcha-service-sdk | GoCaptcha Service SDK Toolkit, includes HTTP/gRPC request interfaces, supports static mode, service discovery, and load balancing. |
| ... |
go-captcha supports the following four CAPTCHA types, each with unique interaction methods, generation logic, and application scenarios:
$ go get -u github.com/wenlng/go-captcha/v2@latestpackage main
// Import modules on demand
import "github.com/wenlng/go-captcha/v2/${click|slide|rotate}"
func main(){
// ...
}The Click CAPTCHA requires users to click specified points or characters on the main image, ideal for quick verification scenarios. It supports two modes:
masterImage): Contains randomly distributed points or characters, typically in JPEG format.thumbImage): Displays the target points or characters to be clicked, typically in PNG format.dots) to verify a match.…click.NewBuilder(click.WithXxx(), ...) OR builder.SetOptions(click.WithXxx(), ...)
| Options | Desc |
|---|---|
| Main Image | |
| click.WithImageSize(option.Size) | Set main image size, default 300x220 |
| click.WithRangeLen(option.RangeVal) | Set range for random content length |
| click.WithRangeAnglePos([]option.RangeVal) | Set range for random angles |
| click.WithRangeSize(option.RangeVal) | Set range for random content size |
| click.WithRangeColors([]string) | Set random colors |
| click.WithDisplayShadow(bool) | Enable/disable shadow display |
| click.WithShadowColor(string) | Set shadow color |
| click.WithShadowPoint(option.Point) | Set shadow offset position |
| click.WithImageAlpha(float32) | Set main image transparency |
| click.WithUseShapeOriginalColor(bool) | Use original graphic color (valid for graphic mode) |
| Thumbnail | |
| click.WithThumbImageSize(option.Size) | Set thumbnail size, default 150x40 |
| click.WithRangeVerifyLen(option.RangeVal) | Set range for random verification content length |
| click.WithDisabledRangeVerifyLen(bool) | Disable random verification length, matches main content |
| click.WithRangeThumbSize(option.RangeVal) | Set range for random thumbnail content size |
| click.WithRangeThumbColors([]string) | Set range for random thumbnail colors |
| click.WithRangeThumbBgColors([]string) | Set range for random thumbnail background colors |
| click.WithIsThumbNonDeformAbility(bool) | Prevent thumbnail content deformation |
| click.WithThumbBgDistort(int) | Set thumbnail background distortion (option.DistortLevel1 to option.DistortLevel5) |
| click.WithThumbBgCirclesNum(int) | Set number of small circles in thumbnail background |
| click.WithThumbBgSlimLineNum(int) | Set number of lines in thumbnail background |
builder.SetResources(click.WithXxx(), ...)
| Options | Desc |
|---|---|
| click.WithChars([]string) | Set text seed |
| click.WithShapes(map[string]image.Image) | Set graphic seed |
| click.WithFonts([]*truetype.Font) | Set fonts |
| click.WithBackgrounds([]image.Image) | Set main image backgrounds |
| click.WithThumbBackgrounds([]image.Image) | Set thumbnail backgrounds |
captData, err := capt.Generate()
| Method | Desc | |----------
No open issues yet, or sync has not completed.