captcha

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Captcha

type Captcha struct {
	W, H, CodeLen      int
	FontSize           float64
	Dpi                int
	FontPath, FontName string
	// contains filtered or unexported fields
}

图形验证码 使用字体默认ttf格式 w 图片宽度, h图片高度,CodeLen验证码的个数 FontSize 字体大小, Dpi 清晰度,FontPath 字体目录, FontName 字体名字 mode 验证模式 0:普通字符串,1:10以内简单数学公式

func NewCaptcha

func NewCaptcha(w, h, CodeLen int) *Captcha

实例化验证码

func (*Captcha) Debug added in v1.2.8

func (captcha *Captcha) Debug()

设置字体大小

func (*Captcha) OutPut

func (captcha *Captcha) OutPut() (string, *image.RGBA)

输出

func (*Captcha) RangeRand

func (captcha *Captcha) RangeRand(min, max int64) int64

获取区间[-m, n]的随机数

func (*Captcha) SetFontName

func (captcha *Captcha) SetFontName(FontName string)

设置字体名称

func (*Captcha) SetFontPath

func (captcha *Captcha) SetFontPath(FontPath string)

设置字体路径

func (*Captcha) SetFontSize

func (captcha *Captcha) SetFontSize(fontSize float64)

设置字体大小

func (*Captcha) SetMode

func (captcha *Captcha) SetMode(mode int)

设置模式

type Image added in v1.0.9

type Image []byte

func Generate

func Generate(w, h, codeLen, mode int, debug bool, opt ...string) (code string, image Image, err error)

"data:image/png;base64," + base64.StdEncoding.EncodeToString(buf.Bytes()) CaptchaGenerate 生成captcha

func (Image) ToBase64String added in v1.0.9

func (i Image) ToBase64String() string

Jump to

Keyboard shortcuts

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