passwd

package
v0.0.0-...-c18a219 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = &Manager{
	Hasher:    PBKDF2(4096),
	SaltBytes: 32,
}

Functions

func Generate

func Generate(raw string) (pwd string, salt string, err error)

Generate create a hashed password with random salt.

func SHA256

func SHA256(pwd, salt string) (string, error)

SHA256 is a Hasher implement with SHA256 algorithm.

func Validate

func Validate(pwd, hash, salt string) bool

Validate validates the password is correct.

Types

type Hasher

type Hasher func(pwd, salt string) (string, error)

func PBKDF2

func PBKDF2(iter int) Hasher

PBKDF2 is a Hasher implement with PBKDF2 algorithm.

type Manager

type Manager struct {
	Hasher
	SaltBytes int
}

func (*Manager) Generate

func (m *Manager) Generate(raw string) (pwd string, salt string, err error)

Generate create a hashed password with random salt.

func (*Manager) Validate

func (m *Manager) Validate(pwd, hash, salt string) bool

Validate validates the password is correct.

Jump to

Keyboard shortcuts

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