hash

package
v0.0.0-...-d5aecf8 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Password

type Password struct {
	// hash过后的密码
	Password string
	// 密码创建时间
	CreateAt int64
	// 密码更新时间
	UpdateAt int64
	// 密码需要被重置
	NeedReset bool
	// 需要重置的原因
	ResetReason string
	// 历史密码
	History []string
	// 是否过期
	IsExpired bool
}

func NewHashedPassword

func NewHashedPassword(password string) (*Password, error)

NewHashedPassword 生产hash后的密码对象

func (*Password) CheckPassword

func (p *Password) CheckPassword(password string) error

CheckPassword 判断password 是否正确 输入的是明文: 123456 需要对比的Hash: $2a$10$ofPPqZ3m37Kp9ROK4ForAOXc5w6SsMKoJ9puCOgIO9yEFFknpYcsO

func (*Password) HistoryCount

func (p *Password) HistoryCount() int

HistoryCount 保存了几个历史密码

func (*Password) IsHistory

func (p *Password) IsHistory(password string) bool

IsHistory 检测是否是历史密码

func (*Password) Update

func (p *Password) Update(new *Password, maxHistory uint, needReset bool)

Update 更新密码

type User

type User struct {
	Account  string
	Password *Password
}

User info

Jump to

Keyboard shortcuts

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