verifycode

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 5 Imported by: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisStore

type RedisStore struct {
	RedisClient *redis.RedisClient
	KeyPrefix   string
}

func (*RedisStore) Get

func (s *RedisStore) Get(id string, is_clear bool) string

func (*RedisStore) Set

func (s *RedisStore) Set(id string, value string) bool

func (*RedisStore) Verify

func (s *RedisStore) Verify(id string, answer string, is_clear bool) bool

验证验证码的正确性

type Store

type Store interface {
	// 保存验证码到存储器
	Set(id string, value string) bool
	// 从存储器中获取验证码的值, 第二个参数代表是否取完就清除存储值
	Get(id string, is_clear bool) string
	// 验证验证码的正确性
	Verify(id string, answer string, is_clear bool) bool
}

定义数字验证码(短信或email发送)相关的存储接口规范 (等着被redis或memcache的等实现)

type VerifyCode

type VerifyCode struct {
	StoreType Store
}

func NewVerifyCode

func NewVerifyCode() *VerifyCode

func (*VerifyCode) CheckAnswer

func (vc *VerifyCode) CheckAnswer(key string, answer string) bool

func (*VerifyCode) Generate

func (vc *VerifyCode) Generate(key string) string

Jump to

Keyboard shortcuts

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