https://github.com/yujiahaol68/captchy
Go package captchy implements flexible generation of image CAPTCHAs.
https://github.com/yujiahaol68/captchy
captcha captcha-png go golang image-captcha package
Last synced: 4 months ago
JSON representation
Go package captchy implements flexible generation of image CAPTCHAs.
- Host: GitHub
- URL: https://github.com/yujiahaol68/captchy
- Owner: yujiahaol68
- License: mit
- Created: 2018-12-24T02:55:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-05T05:24:18.000Z (over 7 years ago)
- Last Synced: 2024-06-20T15:50:34.103Z (almost 2 years ago)
- Topics: captcha, captcha-png, go, golang, image-captcha, package
- Language: Go
- Size: 63.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Package captchy

[](https://goreportcard.com/report/github.com/yujiahaol68/captchy)
[](https://godoc.org/github.com/yujiahaol68/captchy)
```go
import "github.com/yujiahaol68/captchy"
```
captchy implements a abundant CAPTCHAs image generation through flexible config
Split and rotate subImage to against OCRs
Support custom TTF font file or Go builtin fonts
Support export to Base64, PNG, JPEG image
Only std lib so it is clean
**API is still not stable. Not recommend for using in production env !**
## Preview
Generate from very simple to very complex captcha especially for machine, but still friendly to human



## Usage
### Initialize resource
```go
// Load fonts and setup default config
captchy.New(captchy.Default())
```
### Gen solution
```go
rbs := captchy.RandomString()
// Then hash and save rbs into session by yourself
// ..
```
### Gen Image
```go
encoder := captchy.GenerateImg(rbs)
// encoder can encode image into io.Writer, and write it anywhere you prefer.
// It can be local file writer or http response writer
// ..
```
## Reference
[DESIGNING CAPTCHA ALGORITHM: SPLITTING AND ROTATING THE IMAGES AGAINST OCRs](http://cmp.felk.cvut.cz/~cernyad2/TextCaptchaPdf/DESIGNING%20CAPTCHA%20ALGORITHM%20SPLITTING%20AND%20ROTATING.pdf)