Documentation
¶
Index ¶
- Variables
- func BitNumInt63n(bit int) func() int64
- func DefaultFontFace(size int) font.Face
- func GetFontFace(buf []byte, fontSize int, dpi int) (font.Face, error)
- func RandomBytes(n int) []byte
- func RandomBytesHex(n int) string
- func RandomCode() string
- func RandomSpecialBytes(n int, special string) []byte
- func RandomString(n int) string
- type Captcha
- func (c *Captcha) Check(id, code string) (bool, error)
- func (c *Captcha) Create() (id, result string, img image.Image)
- func (c *Captcha) CreateB64() (id, result, data string, err error)
- func (c *Captcha) CreateBytes() (id, result string, buf []byte, err error)
- func (c *Captcha) Draw() (string, *Data, image.Image)
- func (c *Captcha) Get(id string) (*Data, bool)
- func (c *Captcha) Init() *Captcha
- func (c *Captcha) Options(opts ...Option) *Captcha
- func (c *Captcha) Remove(id string)
- type Data
- type Generator
- type ICache
- type ICaptcha
- type Option
- func WithBackground(color color.Color) Option
- func WithExpire(t int64) Option
- func WithFont(fontFace font.Face, size int) Option
- func WithFontByte(buf []byte, fontSize int, dpi int) Option
- func WithFontName(fontName string, fontSize int, dpi int) Option
- func WithFontSize(size int) Option
- func WithFront(color color.Color) Option
- func WithGenerator(generator Generator) Option
- func WithLine(n int) Option
- func WithPoint(n int) Option
- func WithSize(width, hight int) Option
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCodeExpired = fmt.Errorf("验证码已过期") ErrCodeInvalid = fmt.Errorf("验证码无效") )
Functions ¶
func BitNumInt63n ¶
func DefaultFontFace ¶
func RandomBytes ¶
func RandomBytesHex ¶
func RandomCode ¶
func RandomCode() string
func RandomSpecialBytes ¶
func RandomString ¶
Types ¶
type Captcha ¶
type Captcha struct {
Generator Generator
// contains filtered or unexported fields
}
func DefaultCaptcha ¶
func DefaultCaptcha() *Captcha
func (*Captcha) CreateBytes ¶
CreateBytes 创建验证码,返回图片数据[]byte
type ICaptcha ¶
type ICaptcha interface {
// 验证码缓存
Get(id string) (*Data, bool)
Remove(id string)
Check(id, code string) (bool, error)
// Draw 绘制验证码
Draw() (string, *Data, image.Image)
// Create 创建验证码
Create() (string, string, image.Image)
CreateBytes() (string, string, []byte, error)
CreateB64() (string, string, string, error)
}
type Option ¶
type Option func(b *Captcha)
func WithBackground ¶
func WithExpire ¶
func WithFontSize ¶
func WithGenerator ¶
Click to show internal directories.
Click to hide internal directories.