person

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

* * @Author: TheLife * @Date: 2020-2-25 9:00 下午

* * @Author: TheLife * @Date: 2020-2-25 9:00 下午

* * @Author: TheLife * @Date: 2020-2-25 9:00 下午

* * @Author: TheLife * @Date: 2020-2-25 9:00 下午

Index

Constants

View Source
const DataCaptcha = "v"
View Source
const DataCode = "c"
View Source
const DataIsCaptcha = "i"
View Source
const DataSalt = "s"

Variables

This section is empty.

Functions

This section is empty.

Types

type Captcha

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

验证码

func NewCaptcha

func NewCaptcha(personType string, personName string, tryMax int, expireTimeMinute int, c *redis.Client) *Captcha

类型,名称,redis,最大数量,过期时间分钟

func (*Captcha) AddCount

func (c *Captcha) AddCount() (bool, error)

增加一个次数,并且返回增加次数后是否频繁

func (*Captcha) Destroy

func (c *Captcha) Destroy()

删除

func (*Captcha) IsBusy

func (c *Captcha) IsBusy() bool

是否频繁

type Data

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

用户数据

func NewData

func NewData(personType string, personName string, personCode string, c *redis.Client) *Data

func (*Data) Destroy

func (p *Data) Destroy()

删除用户

func (*Data) GetData

func (p *Data) GetData(data []string) (map[string]interface{}, error)

获取数据

func (*Data) IsEmpty

func (p *Data) IsEmpty() bool

判断该用户是否存在

func (*Data) SetData

func (p *Data) SetData(m map[string]interface{}) (bool, error)

设置数据

type Ip

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

Ip

func NewIp

func NewIp(ip string, tryMax int, expireTimeMinute int, c *redis.Client) *Ip

func (*Ip) AddCount

func (c *Ip) AddCount() (bool, error)

增加一个次数,并且返回增加次数后是否频繁

func (*Ip) Destroy

func (c *Ip) Destroy()

删除

func (*Ip) IsBusy

func (c *Ip) IsBusy() bool

是否频繁

type Password

type Password struct {
	Code        string // code 随即码
	Salt        string // 盐
	SaltEncrypt string // 加密盐
}

func (*Password) Check

func (a *Password) Check(hashedPassword, password string) (bool, error)

验证一个hash后的密码

func (*Password) DecryptAndCheck

func (a *Password) DecryptAndCheck(hashedPassword string, inputPass string) (bool, error)

*

  • 解密密码
  • 原理: // AES-128-CBC {padding:Pkcs7,iv:salt}( // md5( md5(salt + 验证码)+sha512(单数位 salt) ).从第三个开始取16个长度 // AES-128-CBC {padding:Pkcs7,iv:md5(salt)的前16位}( // sha512(sha384(salt) + 验证码长度 + 验证码 + md5(双数位 salt)).从第十个开始取16个长度, // sha512(sha384(salt) + 验证码长度 + 验证码 + md5(双数位 salt)) + QQ 密码) // ) // 注: salt 长度必须为16

解密密码与验证

func (*Password) MakePassword

func (*Password) MakePassword(password string) (bcryptPass string, err error)

加密密码

func (*Password) RandSaltAndCode

func (a *Password) RandSaltAndCode(privateKey string) error

生产salt和code

Jump to

Keyboard shortcuts

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