Documentation
¶
Index ¶
- func GeneratePassword(config PasswordConfig) (string, error)
- func GenerateSimplePassword(length int) (string, error)
- func GenerateStrongPassword(length int) (string, error)
- func InitPasswordConfig(config *PasswordConf)
- func VerifyPassword(password string, ph *PasswordHash) bool
- type PasswordConf
- type PasswordConfig
- type PasswordHash
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratePassword ¶
func GeneratePassword(config PasswordConfig) (string, error)
GeneratePassword 生成密码
func GenerateSimplePassword ¶
GenerateSimplePassword 生成简单密码 (仅包含字母和数字)
func GenerateStrongPassword ¶
GenerateStrongPassword 生成强密码 (包含所有字符类型)
func VerifyPassword ¶
func VerifyPassword(password string, ph *PasswordHash) bool
VerifyPassword 验证密码
Types ¶
type PasswordConf ¶
PasswordConf 密码哈希配置
type PasswordConfig ¶
type PasswordConfig struct {
Length int // 密码长度
Numbers bool // 是否包含数字
LowerLetters bool // 是否包含小写字母
UpperLetters bool // 是否包含大写字母
SpecialChars bool // 是否包含特殊字符
MinNumbers int // 最少数字数量
MinLowerCase int // 最少小写字母数量
MinUpperCase int // 最少大写字母数量
MinSpecial int // 最少特殊字符数量
}
PasswordConfig 密码生成配置
type PasswordHash ¶
PasswordHash 密码哈希结构
func HashPassword ¶
func HashPassword(password string) (*PasswordHash, error)
HashPassword 使用单例配置进行哈希
Click to show internal directories.
Click to hide internal directories.