util

package
v0.0.0-...-8b29e06 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 16 Imported by: 0

README

封装可用公共使用的函数库

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GCLimitNumber The number of captchas created that triggers garbage collection used by default store.
	// 默认图像验证GC清理的上限个数
	GCLimitNumber = 10240
	// Expiration time of captchas used by default store.
	// 内存保存验证码的时限
	Expiration = 5 * time.Minute
)

Functions

func BcryptString

func BcryptString(s string) (string, error)

生成加密字符串

func CodeCaptchaCreate

func CodeCaptchaCreate(height, width int) (string, string)

func EncodeMD5

func EncodeMD5(value string) string

EncodeMD5 md5 encryption

func GenRandCode

func GenRandCode(width int) string

func GenerateToken

func GenerateToken(username, password string) (string, time.Time, error)

func GetPage

func GetPage(c *gin.Context) int

func GlobalGet

func GlobalGet(key string)

func GlobalSet

func GlobalSet(key, value string)

func Pagination

func Pagination(url string, totalnum int, page int, pagesize int) (s string)

bootstrap 翻页,命名与 bootstrap 保持一致 Pagination("?page={page}", 30, 1, 20)

func Pagination_tpl

func Pagination_tpl(url, text, active string) string

func RefreshToken

func RefreshToken(token string) (string, time.Time, error)

刷新token 拿老的token换新的token

func VerfiyCaptcha

func VerfiyCaptcha(idkey, verifyValue string) bool

func VerifyString

func VerifyString(s, hash string) bool

验证用户输入的和加密后的是否一致

Types

type Claims

type Claims struct {
	Name     string `json:"name"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string) (*Claims, error)

解析token

type Mail

type Mail struct {
	MailTo  []string
	Subject string
	Body    string
}

func (*Mail) SendMail

func (mail *Mail) SendMail() error

Jump to

Keyboard shortcuts

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