drag_captcha

package module
v0.0.0-...-74cfd8b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

drag-captcha

滑动验证码

结果

Documentation

Overview

* * @Author: ITWorker * @Date: 2021/2/19 13:36 * @Description:拖动验证码

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisCaptchaStore

func NewRedisCaptchaStore(network, address string, opts ...redis.DialOption) *redisCaptchaStore

func WithDragCaptchaBase

func WithDragCaptchaBase(basePath string) func(o *Captcha)

设置底图的存放路径

func WithDragCaptchaDeviation

func WithDragCaptchaDeviation(deviation int) func(o *Captcha)

设置允许误差

func WithDragCaptchaMask

func WithDragCaptchaMask(maskPath string) func(o *Captcha)

设置蒙板的存放路径

Types

type Captcha

type Captcha struct {
	// contains filtered or unexported fields
}

func NewDragCaptcha

func NewDragCaptcha(store CaptchaStore) (*Captcha, error)

func (*Captcha) CreateImage

func (c *Captcha) CreateImage(key string, fns ...func(o *Captcha)) (dstImage *image.RGBA, err error)

生成验证码,并存储 返回文件流 在指定图片上面画蒙板

dst  绘图的背景图。
r 是背景图的绘图区域
src 是要绘制的图
sp 是 src 对应的绘图开始点(绘制的大小 r变量定义了)
mask 是绘图时用的蒙版,控制替换图片的方式。
mp 是绘图时蒙版开始点(绘制的大小 r变量定义了)

func (*Captcha) MaskOffset

func (c *Captcha) MaskOffset() image.Rectangle

func (*Captcha) Valid

func (c *Captcha) Valid(key string, tn float64) bool

验证验证码 tn 为水平方向拖动的像素

type CaptchaStore

type CaptchaStore interface {
	Set(key string, offset image.Rectangle, lifetime time.Duration)
	Get(key string) *image.Rectangle
	Del(key string)
}

Directories

Path Synopsis
* * @Author: Lanhai Bai * @Date: 2021/2/20 16:21 * @Description:
* * @Author: Lanhai Bai * @Date: 2021/2/20 16:21 * @Description:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL