Categorygithub.com/moonrhythm/passwordtool
modulepackage
1.4.0
Repository: https://github.com/moonrhythm/passwordtool.git
Documentation: pkg.go.dev

# README

passwordtool

codecov Go Report Card GoDoc

Password hashing and comparing tool

Install

go get github.com/moonrhythm/passwordtool

Usage

hashed, err := passwordtool.Hash("superman")
if err != nil {
	// ...
}
fmt.Println(hashed)

err = passwordtool.Compare(hashed, "superman")
if err == passwordtool.ErrMismatched {
	// not equal
}
if err != nil {
	// ...
}

Specific algorithm

hc := passwordtool.Bcrypt{Cost: 11}
hashed, err := hc.Hash("superman")
if err != nil {
	// ...
}

err = hc.Compare(hashed, "superman")
if err == passwordtool.ErrMismatched {
	// not equal
}
if err != nil {
	// ...
}

// or

err = passwordtool.Compare(hashed, "superman")
if err == passwordtool.ErrMismatched {
	// not equal
}
if err != nil {
	// ...
}

License

MIT

# Functions

Compare compares hashed and password returns nil if hashed and password equal.
Hash hashes password using default strategy.

# Variables

Errors.
Errors.
Hasher strategies.
Hasher strategies.
Hasher strategies.

# Structs

Argon2id strategy.
Bcrypt strategy.
BcryptHash strategy.
PBKDF2 strategy.
Scrypt strategy.

# Interfaces

HashComparer interface.
Hasher type.