# README
Captcha
base64 captcha otp based on redis and base64Captcha.
Usage
go get -u github.com/go-cinch/common/captcha
import (
"context"
"fmt"
"github.com/go-cinch/common/captcha"
"github.com/redis/go-redis/v9"
)
func main() {
client := redis.NewClient(&redis.Options{
Addr: "127.0.0.1:6379",
DB: 0,
})
c := captcha.New(
captcha.WithRedis(client),
captcha.WithCtx(context.Background()),
)
// get captcha id and base64 img
id, img := c.Get()
fmt.Println(id, img)
// verify captcha by str and id
fmt.Println(c.Verify(id, "1234"))
}
Options
WithRedis
- redis client, default 127.0.0.1:6379WithCtx
- context, convenient log trackingWithPrefix
- redis cache key prefix, default captcha_WithExpire
- key expire time, default 5 minutesWithNum
- number of characters, default 4
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author