pwd

package
v1.8.87 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Argon2Time    = 4         // Argon2 参数,迭代次数
	Argon2Memory  = 64 * 1024 // Argon2 参数,内存大小(KB)
	Argon2Threads = 1         // Argon2 参数,线程数
	Argon2KeyLen  = 32        // Argon2 参数,生成的密钥长度
	SaltSize      = 16        // 盐值长度
	SplitChar     = ":"
)

Argon2 参数

Variables

View Source
var (
	ErrGenerateSaltFailed = errors.New("failed to generate salt")
	ErrDecodeSaltFailed   = errors.New("failed to decode salt")
	ErrSplitHashInvalid   = errors.New("invalid hash format")
	ErrDecodeHashFailed   = errors.New("failed to decode hash")
)

定义常见错误消息

View Source
var (
	ErrInvalidSecPwdLength      = errors.New("password must be 6 digits")
	ErrInvalidSecPwdConsecutive = errors.New("password must not contain three consecutive identical digits")
	ErrInvalidSecPwdSequential  = errors.New("password must not contain three or more sequential digits")
	ErrCiphertextTooShort       = errors.New("ciphertext too short")
	ErrInvalidSHA256Length      = errors.New("SHA256 hash must be 64 characters long")
	ErrInvalidSHA256Format      = errors.New("SHA256 hash must be a valid hexadecimal string")
)

定义常见错误消息

Functions

func GenSalt added in v1.8.16

func GenSalt() (string, error)

GenSalt .

func IsCorrect added in v1.8.16

func IsCorrect(password, hashStr string) (bool, error)

IsCorrect .

func SplitHash

func SplitHash(hash string) []string

SplitHash .

func ToHash added in v1.8.18

func ToHash(password string) (string, error)

ToHash .

func ValidateSHA256 added in v1.8.69

func ValidateSHA256(hash string) error

ValidateSHA256 验证字符串是否为 64 位长度的 SHA-256 哈希值

func ValidateSixNumberAsPwd added in v1.8.68

func ValidateSixNumberAsPwd(secPwd string, length int) error

ValidateSixNumberAsPwd 验证指定长度的纯数字字符串密码

Types

This section is empty.

Jump to

Keyboard shortcuts

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