passhash

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EasyHash

func EasyHash(rawPwd string, saltLen int) (salt string, pwdHash string, err error)

传入原始密码和盐长度,返回盐和哈希后的密码 err只有在生成盐时才可能出错,与底层操作系统或硬件提供的随机数生成器有关,概率很小

func GenerateSalt

func GenerateSalt(length int) ([]byte, error)

GenerateSalt generates a random salt of specified length

func HashPassword

func HashPassword(rawPwd string, salt []byte) string

HashPassword hashes a password using PBKDF2 with a given salt and iteration count. keyLen is the length of the resulting hash in bytes,可任意改 33 34 64 啥都行 iterations is the number of iterations to use in PBKDF2 , 既重复进行多少次哈希计算(对哈希后的结果再哈希,就更难破译)

func Verify

func Verify(rawPwd, pwdHash string, salt string) bool

验证密码是否正确,传入原始密码、哈希后的密码和盐

Types

This section is empty.

Jump to

Keyboard shortcuts

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